grrrrrrrrrrrrr grrrrrrrrrrrrr - 2 months ago 15
C# Question

Different version of a nuget package is being installed and referenced during build to the project references and packages

On our build server I have a solution where all projects reference version 3.6 of the rabbit client tools Nuget package. However when I build the solution on the build server it seems to be downloading version 4.0.2 of the rabbit client tools. Even though there is no reference to this dll either in my code, or the easynetq library that I'm also using alongside this as far as I can tell.

I've tried:


  • Clearing the nuget cache on the server

  • Cleaning the checkout directories

  • Changing the rabbit client nuget version

  • Checked the assembly binding versions in the app.config.



All are correct before the build occurs.

As an aside, I don't know if this will make much difference, but the assembly redirects in the app and web configs for my apps are also being switched to 4, even though my local code is 3.6.5.

Also, this does seem to build fine through visual studio 2015 so I'm assuming this must be something that can get left behind on the server somewhere to do with Nuget.

Packages.Config:

<packages>
<package id="EasyNetQ" version="0.62.1.445" targetFramework="net452" />
<package id="EasyNetQ.Management.Client" version="0.51.1.105" targetFramework="net452" />
<package id="GuerrillaNtp" version="1.0.0.0" targetFramework="net452" />
<package id="log4net" version="2.0.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Diagnostics" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Hosting" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.SelfHost" version="3.0.1" targetFramework="net452" />
<package id="mongocsharpdriver" version="2.2.3" targetFramework="net452" />
<package id="MongoDB.Bson" version="2.2.3" targetFramework="net452" />
<package id="MongoDB.Driver" version="2.2.3" targetFramework="net452" />
<package id="MongoDB.Driver.Core" version="2.2.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="OctoPack" version="3.0.45" targetFramework="net452" developmentDependency="true" />
<package id="Owin" version="1.0" targetFramework="net452" />
<package id="RabbitMQ.Client" version="3.6.5" targetFramework="net452" />
<package id="Swashbuckle.Core" version="5.4.0" targetFramework="net452" />
<package id="Topshelf" version="3.1.2" targetFramework="net452" />
</packages>

Answer

Try running a "manual nuget restore" on the build server....just to see if that is working correctly. Temporarily push it to a different "packages" directory. I've used "MyPackages" here.

nuget.exe restore .\packages.config -PackagesDirectory .\MyPackages

You can get the command line nuget.exe from here:

https://dist.nuget.org/index.html

The key here will be:

Which subfolders are you getting?

".\MyPackages\RabbitMQ.Client.4.0.2"

and/or

".\MyPackages\RabbitMQ.Client.3.6.5"

If the "manual nuget restore" is working correctly (which in this case would be only getting the subfolder ".\MyPackages\RabbitMQ.Client.3.6.5"), then there is something outside of the normal nuget workflow that is happening during your build.

OP ANSWER EDIT This line of investigation didn't fully solve the issue but did point to something else changing the packages file whilst the build was running. It ended up being TeamCity having an Auto Update feature in its nuget package restore, which wasn't being logged.

Comments