How to detect MVC version?

Topics: General
May 20, 2012 at 7:50 PM
Edited May 20, 2012 at 7:51 PM

I've built a NuGet Package for MVC 3 applications.  Now with MVC 4 some of the views break because HTML Helpers have an additional parameter necessary.  It also needs a new assembly dependency section for MVC 4 added to the web.config in order to work.

Is there a way of creating a NuGet package without PowerShell, that can detect which version of MVC is installed in the host application, so I can add the correct versions of the Views and the web.config.transform?

I'm hoping there is some solution similar to detecting which .Net version by simply putting files in that .Net version folder.

Is this possible and if so, what is the NuGet configuration steps to get this to work?  I've looked at the docs and there doesn't seem to be information on how to do this.

If not, then is it possible via PowerShell?  I have never written anything in PowerShell and if this is the only way to handle this issue, I could use a push in the right direction.

Any help with this is appreciated.


May 21, 2012 at 4:52 PM

Instead of version detection, you should create two versions of the package, which adds Mvc ( as a dependency with the right version ranges limits version ranges.

May 22, 2012 at 1:33 AM

Hmmm, that's a good idea.  Thanks.