Search code examples
nugetteamcitycommand-promptgit-commitnuspec

Adding git commit-id to the .nuspec-file


Trying to add git commit id to the .nuspec - for now just from the command prompt and then from teamcity.

Is there a way to do that?

Is this the right direction "nuget pack -Properties Configuration=Release;commitId=SomethingSomething" or am I totally lost?

See picture for more info


Solution

  • TC has a parameter %build.vcs.number.1% which return the commit has of first attached VCS of your configuration. You can use this value

    Some replacement tokens in a NuSpec file are pulled from the assembly at the point of packaging it. Just set the replacement value as <commit>$mycommit$</commit>

    nuget pack -Properties "mycommit=%build.vcs.number.1%;Something=Else"
    

    More details can be found here - NuSpec documentation

    If you add a NuGet Pack build step and how the advanced options, you should be presented with an input field to enter the properties in TeamCity