it:ad:nuget:howto:add_packages_to_newly_checked_out_solutions

IT:AD:Nuget:HowTo:Add Packages To Newly Checked Out Solutions

Since Nuget 1.6, the rehydration step is backed into a Project's file by Nuget (the Team Lead has to 'prepare' the solution, but that step is trivial), by adding

#!xml
  <Import Project="$(SolutionDir)\.nuget\nuget.targets" />

to the bottom of the project *.csproj file, that points to a folder in your solution directory that contains:

#!xml
 <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
 <NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
 <PackagesConfig>$(ProjectDir)packages.config</PackagesConfig>
 ...etc...

Which it can then invoke to check and download assemblies. You get the point (ie, I don't want to go into the nitty gritty here…JFGI.

Much as I like NuGet, there are still some problems with it, as of version 1.7.
Currently…you can't. This may change in the future. Keep an eye on this issue 1779

The current consensus is:

  • Will work for first checkout from Source Control
  • After that…until the above is done:
    • * Remove the References
    • * Rename 'packages.config' to get it out of the way (eg: 'packages.config.txt')
    • * Nuget in the packages again (referencing the list in 'packages.config.txt' to ensure you get everything.
    • * Then Clean/Rebuild the assembly.
    • * Yes It's annoying, I don't have a better answer just yet, and I can't wait till they get this sorted out.

Common issues to watch out for:

  • The Team Lead forgot to prepare the Solution (right-click on the Solution, and Select Prepare for … can't remember exactly what it says, but it adds to the solution the .nuget directory.
  • The Team Lead forgot to CheckIn the .nugetnuget.exe* – a binary. Without doing that, devs who checkout the code can't run any scripts.
    • * A quickfix is to simply copy/paste the nuget.exe file from another Solution, and put it into the .nuget directory.

    * Strange things…Not all the nuget revision numbers seem to be updating when I use 'update-package' at the Package Manager Console

    • Yeah. That's annoying. It's because update-package seems to not be …imcomplete. At least Nuget 1.6's version of it. It seems to do a mostly good job…but fail to update all solutions. When downloading a new solution, or simply feel that things are acting wierd, I ensure that each assembly has the latest of each Reference, by invoking 'update-package' on every assembly in the solution. Annoying, but it doesn't really take that long either. Hopefully they'll fix it soon.

update package -project XAct.Examples.SomeApp.Hosts.UnitTests
...
update package -project XAct.Examples.SomeApp.Hosts.Application
...
update package -project XAct.Examples.SomeApp.Hosts.Infrastructure.IoC
...
update package -project XAct.Examples.SomeApp.Hosts.Infrastructure.IoC.K2
...
update package -project XAct.Examples.SomeApp.Hosts.Infrastructure.IoC.UT
...
update package -project XAct.Examples.SomeApp.Hosts.Infrastructure.Services
...

  • /home/skysigal/public_html/data/pages/it/ad/nuget/howto/add_packages_to_newly_checked_out_solutions.txt
  • Last modified: 2023/11/04 01:51
  • by 127.0.0.1