You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not 100% sure this is a bug and not user error, but it feels like a bug, so I apologize if I've misunderstood the scenario 😊.
Repro setup
Use a simple project setup like this:
<ProjectSdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>nbgv_rebuild</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReferenceInclude="Nerdbank.GitVersioning"Version="3.6.139">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<TargetName="PrintPackageVersion"AfterTargets="_GetOutputItemsFromPack">
<!-- Stand in for custom targets that use the package -->
<MessageText="_OutputPackItems = @(_OutputPackItems)"Importance="High" />
</Target>
</Project>
In my case I'm inside a git repo, but with no version.json and no commits.
Correct output
If I do a standard build like this:
dotnet clean && dotnet build /tl:off
I get output like this
Build succeeded in 0.5s
Determining projects to restore...
All projects are up-to-date for restore.
nbgv-rebuild -> D:\Projects\nbgv-rebuild\bin\Debug\net8.0\nbgv-rebuild.dll
_OutputPackItems = D:\Projects\nbgv-rebuild\bin\Debug\nbgv-rebuild.0.0.0-g.nupkg;D:\Projects\nbgv-rebuild\obj\Debug\nbgv-rebuild.0.0.0-g.nuspec
The package nbgv-rebuild.0.0.0-g is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important.
Successfully created package 'D:\Projects\nbgv-rebuild\bin\Debug\nbgv-rebuild.0.0.0-g.nupkg'.
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.24
Note the version of 0.0.0-g. That's expected given the setup.
Incorrect output
If I do a clean (or a Rebuild) like this:
dotnet clean/tl:off
I get output like this:
Build started 7/29/2024 11:58:40 AM.
1>Project "D:\Projects\nbgv-rebuild\nbgv-rebuild.sln" on node 1 (Clean target(s)).
1>ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
1>Project "D:\Projects\nbgv-rebuild\nbgv-rebuild.sln" (1) is building "D:\Projects\nbgv-rebuild\nbgv-rebuild.csproj" (2) on node 1 (Clean target(s)).
CoreClean:
Deleting file "D:\Projects\nbgv-rebuild\bin\Debug\net8.0\nbgv-rebuild.deps.json".
Deleting file "D:\Projects\nbgv-rebuild\bin\Debug\net8.0\nbgv-rebuild.dll".
Deleting file "D:\Projects\nbgv-rebuild\bin\Debug\net8.0\nbgv-rebuild.pdb".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\nbgv-rebuild.GeneratedMSBuildEditorConfig.editorconfig".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\nbgv-rebuild.AssemblyInfoInputs.cache".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\nbgv-rebuild.AssemblyInfo.cs".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\nbgv-rebuild.csproj.CoreCompileInputs.cache".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\nbgv-rebuild.dll".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\refint\nbgv-rebuild.dll".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\nbgv-rebuild.pdb".
Deleting file "D:\Projects\nbgv-rebuild\obj\Debug\net8.0\ref\nbgv-rebuild.dll".
PrintPackageVersion:
_OutputPackItems = D:\Projects\nbgv-rebuild\bin\Debug\nbgv-rebuild.1.0.0.nupkg;D:\Projects\nbgv-rebuild\obj\Debug\nbgv-rebuild.1.0.0.nuspec
2>Done Building Project "D:\Projects\nbgv-rebuild\nbgv-rebuild.csproj" (Clean target(s)).
1>Done Building Project "D:\Projects\nbgv-rebuild\nbgv-rebuild.sln" (Clean target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.51
Note that now the version of the package was 1.0.0 and that the package wasn't cleaned. I'd expect to also see this section in the output:
I'm not 100% sure this is a bug and not user error, but it feels like a bug, so I apologize if I've misunderstood the scenario 😊.
Repro setup
Use a simple project setup like this:
In my case I'm inside a git repo, but with no version.json and no commits.
Correct output
If I do a standard build like this:
I get output like this
Note the version of
0.0.0-g
. That's expected given the setup.Incorrect output
If I do a clean (or a Rebuild) like this:
I get output like this:
Note that now the version of the package was
1.0.0
and that the package wasn't cleaned. I'd expect to also see this section in the output:but I don't.
My (likely incorrect) diagnosis
It seems that nbgv isn't hooking into Clean targets correctly and thus the default and incorrect version is being used.
The text was updated successfully, but these errors were encountered: