2
votes

I recently started to create my own NuGet packages and today I wanted to set up a build on VSTS, that automatically generates a NuGet package out of a VS-Project and then pushes it to a VSTS-Feed. After a while I was successful with building the project and pushing it to the feed. For continuous integration I then wanted to add a version number, that I usually write in the AssemblyInfo file. This lead me to the problem I do have now:

I can see this number being changed in the log of the build and also when I download it and integrate it locally into VS, the version is right.

BUT not on my feed. My feed totally ignores the number. The version number seems to be 1.0.0 somehow, and never changes. So after building again, I just get an error message, because:

The feed already contains 'SampleNuGetPackage 1.0.0'

I hope this information and these screenshots are enough for you to understand my problem :)

3

3 Answers

1
votes

To touble shooting the issue, please check with below aspects:

1. Check if you change the Assmbly Version correctly in AssemblyInfo.cs file

Assume you need to changes assembly version from 1.0.0.0 to 1.0.1.0, you should change below lines in AssemblyInfo.cs:

[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]

Note: the assembly version format is major.minor.build.revision, and the first three numbers can be reflected in package version. So you just need to change the first three numbers.

2. Check if the generated variable’s name is AssemblyInfo.AssemblyVersion

Add a PowerShell task after Assembly Info Reader task to list all the variables. Settings for the PowerShell task as below:

Type: Inline Script

Inline Script: Get-childItem env:

Assume you have changed the version in in AssemblyInfo.cs as 1.0.1.0, then queue the build. In the build log of Powershell task, find the variable name start with ASSEMBLYINFO_ and the value is 1.0.1.0. If there has the variable named ASSEMBLYINFO_ASSEMBLYVERSION and the value is 1.0.1.0, that means you used the environment AssemblyInfo.AssemblyVersion correct in NuGet pack task. Else you should use the correct variable name with value 1.0.1.0.

1
votes

After checking the whole build process again, I noticed my error. In the settings for the NuGet pack command there exists the property: Configuration to package. This property shouldn't be set, if you aren't using the .csproj file to generate the NuGet package, which I was not. After removing the value from the property the build process generated the package properly and added it to the feed, containing the version number I set in the AssemblyInfo file.

0
votes

I am another intern hopping in to try and help you out!

So, I see that you are using automatic versioning, based on an environment variable:

Assemblyinfo.Assemblyversion

This is the version number you have stored in the CSProj file inside the visual studio. You can change this in the code by the following means:

Right click project>Properties>Application>AssemblyInformation

To change this property, you will have to make a change to the code and push it to the repo every single time, rather that this, you should use some other method of versioning I think. Maybe using build #?