Skip to content
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

Need help achieving proper version control with GitInfo. #161

Closed
kikaragyozov opened this issue Jun 17, 2021 · 1 comment
Closed

Need help achieving proper version control with GitInfo. #161

kikaragyozov opened this issue Jun 17, 2021 · 1 comment
Labels

Comments

@kikaragyozov
Copy link

kikaragyozov commented Jun 17, 2021

Greetings all.

I've no clue how MSBuild targets work, but I somehow managed to get some code that ended up doing part of what I wanted, but when I introduced GitInfo.txt, problems started occuring.

My .csproj file contains the following 2 targets:

<Target Name="PopulateNETSDKAssemblyVersion" AfterTargets="_GitPopulateVersionInfo">
		<PropertyGroup>
			<Version>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).0</Version>
			<FileVersion>$(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch).$(GitCommits)</FileVersion>
			<PackageVersion>$(FileVersion)</PackageVersion>
			<InformationalVersion>$(FileVersion)+branch.$(GitBranch).commit.$(GitCommit)</InformationalVersion>
		</PropertyGroup>
		<Message Importance="high" Text="PackageVersion: $(PackageVersion)" />
	</Target>

	<Target Name="CopyPackage" AfterTargets="Pack">
		<Copy SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg" DestinationFolder="\someDestionation" />
	</Target>

This works correctly and packs nuget packages with versions "0.0.0." when ran with MSBuild.exe \t:pack, but when I introduced separate GitInfo.txt files with versions 1.0.0, the build fails, because the packing created a nuget versioned as "1.0.0", whereas the file I'm looking to copy is "1.0.0.0" - error.

Could someone please help me out? I know I can supply a version by using /p:PackageVersion=X.X.X.X but I don't know how to make that happen as part of my .csproj file.

EDIT: Seems the issue is coming from the fact that $(GitCommits) is 0, and because I'm sending 1.0.0.0 as the version, it gets trimmed to 1.0.0?

@kikaragyozov
Copy link
Author

Seems this is related to #NuGet/Home#3050

@kzu kzu added the invalid label Aug 26, 2021
@devlooped devlooped locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants