Skip to content

Issue accessing GitInfo variables for Multi-targeted project in MSBuild when packing into nuget #187

@kikaragyozov

Description

@kikaragyozov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions