I am trying to embed the library within a WPF app targeting netcoreapp3.0.
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:
1>------ Build started: Project: VersioningTest, Configuration: Debug Any CPU ------
1>MainWindow.xaml.cs(13,21,13,33): error CS0103: The name 'ThisAssembly' does not exist in the current context
1>Done building project "VersioningTest_deh445kx_wpftmp.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Title = typeof(MainWindow).Assembly.GetName().Version.ToString(); instead the version is 0.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(); and nbgv install. Version displayed is 1.0.0.0.My project file:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.26">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
I did not find any issues related to this issue.
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 https://github.com/NuGet/Home/issues/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?
you didn't _commit_ your version.json file
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 <Project> tag:
<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:
<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 https://github.com/dotnet/Nerdbank.GitVersioning/issues/404#issuecomment-554416254 isn鈥檛 working for me. Could you please reopen this issue so we can look into this? I鈥檓 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!