-
-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WPF: Build fails in wpftmp.csproj when ThisAssembly
is used
#404
Comments
The issue with WPF is it has this horky "inner build" which builds a temporary project file that doesn't properly import the nuget imported files. This is tracked by NuGet/Home#5894. As for version numbers being 0.0.0.0, that may be because you didn't commit your version.json file. Did you try that? |
ThisAssembly
is used
Workaround for #404 till the dependent bugs we have open against NuGet are resolved. This workaround is only complete with two xml snippets added to a WPF project: Add this just under the opening `<Project>` tag: ```xml <Import Project="$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.props" Condition=" '$(_TargetAssemblyProjectName)' != '' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.props')" /> ``` Add this just above the closing `</Project>` tag: ```xml <Import Project="$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.targets" Condition=" '$(_TargetAssemblyProjectName)' != '' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.targets')" /> ``` This is tested to work both for .NET Framework WPF projects and .NET Core WPF projects.
Workaround for #404 till the dependent bugs we have open against NuGet are resolved. This workaround is only complete with two xml snippets added to a WPF project: Add this just under the opening `<Project>` tag: ```xml <Import Project="$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.props" Condition=" '$(_TargetAssemblyProjectName)' != '' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.props')" /> ``` Add this just above the closing `</Project>` tag: ```xml <Import Project="$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.targets" Condition=" '$(_TargetAssemblyProjectName)' != '' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.targets')" /> ``` This is tested to work both for .NET Framework WPF projects and .NET Core WPF projects.
Yeah. I forgot that. 🤦♂ Nevertheless I assumed that the library is working when this happened. |
The best I can do given current NuGet/WPF bugs is now released in nerdbank.gitversioning v3.0.28. Upgrade to that and apply the following workaround: Add this just under the opening <Import Project="$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.props"
Condition=" '$(_TargetAssemblyProjectName)' != '' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.props')" /> Add this just above the closing <Import Project="$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.targets"
Condition=" '$(_TargetAssemblyProjectName)' != '' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOutputPath)$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g.targets')" /> This is tested to work both for .NET Framework WPF projects and .NET Core WPF projects. |
Now it is working. Thank you for the quick workaround 😄 ! |
@AArnott Unfortunately, this issue is happening with one of my projects, and the workaround you proposed in #404 (comment) isn’t working for me. Could you please reopen this issue so we can look into this? I’m using NBGV 3.1.74, which is larger than the version that you specified (3.0.28). Thanks! |
Please disregard my earlier comment; I have since fixed the issue. Sorry to bother you! |
To aid others, I found another instance where the workaround above fixes the issue below. You can get in this situation with usage of
|
It is also worth noting that the WPF team finally fixed this bug, although you need a recent SDK to get the fix. Details are here: microsoft/CsWin32#7 |
I am having this problem on a project that is not WPF ( I get the EDIT: I removed NDGV from some projects in the solution that didn't need it, cleared out |
@AArnott ok, I am back. I am trying to apply this to an ASP.NET full framework application. I can build locally, but in the pipeline on ADO I still get the error above. I was able to solve it locally by adding the |
What OS is your build server running? |
I am trying to embed the library within a WPF app targeting netcoreapp3.0.
Repro
NerdBank.GitVersioning
via NuGet UI.Title = ThisAssembly.GitCommitId;
to the MainWindow constructor.The IntelliSense suggests ThisAssembly and also shows the right constant values in the tooltip (the class is generated somewhere), but when it comes the build:
What I tried then
Title = typeof(MainWindow).Assembly.GetName().Version.ToString();
instead the version is0.0.0.0
.nbgv install
via packet manager console on solution(= git repo root) level, after installing it as a global tool. Still did not work. On project level did not work either (created files at same location).Title = typeof(MainWindow).Assembly.GetName().Version.ToString();
andnbgv install
. Version displayed is1.0.0.0
.Context
My project file:
I did not find any issues related to this issue.
The text was updated successfully, but these errors were encountered: