6

We have many libraries which are build in a CI, which deploy prereleases every time they build. Other projects depend on these and automatically updates them during build.

But the references are set with the Specific Version = true, which means that increasing the version number on these dlls causes the build to fail.

How can I control the setting of the property?

Julius
  • 946
  • 1
  • 10
  • 26

1 Answers1

5

You cannot change NuGet's behaviour without changing its source code. NuGet will always sets SpecificVersion to true when adding a non-GAC assembly from within Visual Studio.

You would need to run some sort of post build script to fix the references or manually change them.

Not sure exactly how you are updating the projects in your CI server. If you use NuGet.exe update project.csproj then that will update to the latest NuGet package and will not set SpecificVersion to true. However the command line application does not support PowerShell scripts or content files, only references will be updated. This also assumes that there is an update available otherwise the reference will not be modified.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • I use NuGet restore from command line to get all packages for my solution. The packages are versioned like 1.0.0-latest, where none of the version number change for a new build, I was not able to make that work from the command line. The dll do get a fourth version number which is the svn number. This number is increased for each build. – Julius Sep 30 '15 at 12:57
  • In your answer you say nuget will always set SpecificVersion to true, but then later on your say if you use Nuget.exe update project.csproj then that will update to the latest NuGet package and will not set SpecialVersion (assume you meant SpecificVersion) to true. By not setting SpecificVersion does that mean it will use the default which seems to be true? – Eric Roller Apr 15 '16 at 19:11
  • The command line nuget behaves differently to nuget 2 in visual studio. – Matt Ward Apr 15 '16 at 21:31
  • As to what specificversion does there are answers on stackoverflow which explain how it works better than I can – Matt Ward Apr 15 '16 at 21:38
  • 1
    Like this one: https://stackoverflow.com/questions/24022134/how-exactly-does-the-specific-version-property-of-an-assembly-reference-work-i – tom redfern May 25 '18 at 14:55