question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WPF's inner build (wpftmp.csproj) preprocess view lies

See original GitHub issue

Given a WPF project such as:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp5.0</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Nerdbank.GitVersioning" Version="3.1.13-beta">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Where MainWindow.xaml.cs includes the line:

Title = ThisAssembly.AssemblyFileVersion;

A build error follows. This is because of https://github.com/NuGet/Home/issues/5894, which is beside the point. The point is, in investigating the failure, I use the /bl switch and load the file into msbuild structured log viewer. I then find the wpftmp.csproj and click the Preprocess command on it, which shows me this:

image

From this screenshot you’ll see that nerdbank.gitversioning.targets have been imported. But in fact, I don’t believe they have, since it it was imported there would not be a build failure. Also the side effects of having imported it such as influence on project properties would be visible in the evaluation model which the Properties tree within the structured log viewer does not show are present. Finally, when I run msbuild WpfApp3_meucdeke_wpftmp.csproj /p:_TargetAssemblyProjectName=WpfApp3,IntermediateOutputPath=obj\Debug\netcoreapp5.0\,AssemblyName=WpfApp3 /pp:out.xml myself and inspect the out.xml file, there’s no trace of the nerdbank.gitversioning.targets file having been imported.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
KirillOsenkovcommented, Nov 15, 2019
1reaction
AArnottcommented, Nov 15, 2019

Sure. I’ll try. Netcoreapp5.0 isn’t important though. It happens on 3.0 too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF: Build fails in wpftmp.csproj when `ThisAssembly` is ...
The issue with WPF is it has this horky "inner build" which builds a temporary project file that doesn't properly import the nuget...
Read more >
Build produces *wpftmp* folder for every application.
We have a solution with around 250 projects. There are around 15 projects in it the produce a console or wpf application. With...
Read more >
What purpose does a .csproj file serve?
Currently, Visual organizes several projects in a solution. A solution is described by a .sln file that is not XML and contains references...
Read more >
WPF App Using new csproj format
I am experimenting with migrating a WPF project, defined using the old csproj format, to the new format under VS 2017.
Read more >
Common MSBuild Project Properties
Learn about common MSBuild project properties that can be defined or used in project files or included in .targets files that MSBuild ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found