Question

I coordinate a project (Fluent Assertions.MVC) which has a separate builds for MVC 3 and 4. At the moment it is distributed via two NuGet packages.

Is this the best (only?) way, or is it possible to ship one package and have NuGet reference the correct .dll in the target project?

Was it helpful?

Solution

The solution is quite simple:

  • you add into your package the DLLs for all supported versions of MVC (3 and 4 in your case);
  • then write install.ps1 script to find out what version of MVC is used in the target project and remove unnecessary DLLs from project references.

Here you can find more detailed instructions and an example of install.ps1 script: http://blogs.korzh.com/2013/12/nuget-package-different-mvc-versions.html

OTHER TIPS

Currently NuGet can install separate sets of reference dlls by target framework, such as .net40, net45, netcore45 etc. Please refer to http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package for more details.

For MVC3 vs. MVC4 though, the best I can think of is to have install.ps1 in your package and try to use DTE objects to determine which version of MVC the project is using (maybe by checking MVC assembly version) and then install references accordingly.

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