GitInfo
GitInfo copied to clipboard
Issue accessing GitInfo variables for Multi-targeted project in MSBuild when packing into nuget
The project targets the following frameworks:
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
I have the following target defined in my .csproj file:
<Target Name="PopulateInfo" DependsOnTargets="GitInfo" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<Version>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).0</Version>
<FileVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).$(GitCommits)</FileVersion>
<PackageVersion>$(FileVersion)</PackageVersion>
<InformationalVersion>$(FileVersion)+branch.$(GitBranch).commit.$(GitCommit)</InformationalVersion>
</PropertyGroup>
</Target>
I'm trying to build & pack a nuget package, but it always ends up with the same version of 1.0.0.
I'm using the following command to try and build my package:
MSBuild.exe /t:Clean;Build;Pack /p:Configuration=Release