Question

I am using NuGet packages with local feed located in chosen directory. Let's call it RepositoryDir. I am pushing results of my own builds as nuget packages here. Additionally I've got multiple solutions that reference each other (as nuget packages)

What I need to accomplish is situation like that:

 1. Consider two solutions A and B. B needs A package to build.
 2. Build solution A and push A.1.1.0.0.nupkg to RepositoryDir with nuget.exe 
 3. Clear contents of packages folder for B solution 
(clear B/packages dir, A.1.0.0.0.nupkg for example). 4. Update A library in B solution.
nuget.exe update B.sln -Source ../RepositoryDir 5. Install A library in B solution
nuget.exe restore B.sln -Source ../RepositoryDir

I have this assumption in 3. because on TeamCity server there will be empty packages directory provided during update.

What is blocking this scheme from working is actually nuget update saying:

Looking for installed packages in '..\packages'

This means that nuget does not update A library for B solution because there is no previous version of A in packages directory. Why is that working this way? I supposed that nuget looks to packages.config and looks for libraries to update here.

Is there a way to always download newest version of A during B build?

Was it helpful?

Solution

When NuGet updates a package it will uninstall the old package and then install the new one. In order to uninstall the old package it needs information from the package, such as what references were included, so it can uninstall everything from the project. That information is not available from the packages.config file. This is true when using NuGet inside Visual Studio to update a package or when using "nuget.exe update" from the command line.

So you would need to change the order in your list with the restore the packages for B being executed before the packages are updated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top