3

I've started using NuGet to install PostSharp into my projects and this is what I routinely run into:

1) Start new solution and project
2) Add existing project(s) (that new project references) that already use(s) PostSharp
3) Use NuGet to add PostSharp to the new project
4) Try to compile/run but get errors about not being able to load PostSharp properly
5) Realize the new project is using a slightly newer version of PostSharp
6) Use NuGet manager to remove/readd Postsharp to existing projects so they're up to date

Is there a way that I can have NuGet load the same version of PostSharp into new projects that is already being used in the older projects or does NuGet only get the very latest?

BVernon
  • 3,205
  • 5
  • 28
  • 64

2 Answers2

2

The nuget command will specify a specific version if the older versions are available.

EX: Install-Package NUnit -Version 2.6.1

The above example is for NUnit, but I would check to see if the package you're using is available in multiple versions

TGH
  • 38,769
  • 12
  • 102
  • 135
  • I'm kind of a noob to NuGet. I've just used the GUI to search for PostSharp and install it that way. I suppose this means I will need to start using the command line then? – BVernon Oct 29 '13 at 19:26
  • The example I gave assumes the command line. I am not sure if this package exits in multiple versions, but it's worth a try – TGH Oct 29 '13 at 19:27
  • About to find out... soon as I figure out how to bring up the NuGet command line :) – BVernon Oct 29 '13 at 19:29
  • In Visual Studio it's Tools -> Library Package Manager -> Package Manager Console – TGH Oct 29 '13 at 19:30
  • Got it, and yeah that worked perfect. Will accept as answer as soon as SO lets me :) – BVernon Oct 29 '13 at 19:33
1

You actually can install the same version of the NuGet package into the new project that is already being used for the older projects in the solution.

  • Right click on your solution and select "Manage NuGet Packages for Solution".
  • Look at the "Installed packages" and click on the package you're interested in (PostSharp in your case)
  • Then click the "Manage" button and add check-boxes on all projects where you want this package to be installed

I find that managing packages on a solution level is a better way, otherwise it's easy to run into problems with many different versions of the same packages throughout the solution.

AlexD
  • 5,011
  • 2
  • 23
  • 34