I'm creating a nuget package that I want to be compatible for both MVC2 and MVC3 applications (all on .net 4.0).
The problem is, I want to add some namespaces to the web.config file (like so):
<pages>
<namespaces>
<add namespace="NewPackage.Web" />
</namespaces>
</pages>
But for razor, I'd have to put it in as such:
<system.web.webPages.razor>
<pages>
<namespaces>
<add namespace="NewPackage.Web" />
</namespaces>
</pages>
</system.web.webPages.razor>
But of course, this wouldn't work for MVC2. So I was hoping for some way to conditionally run a web.config.transform only if mvc3 is detected. I understand nuget doesn't really have the capability to do this but I was wondering about powershell. I know you can create an install.ps1 and I know it can detect a project's references but can it detect a reference version number and then run a web.config.transform? Is there some better way?
I know I could create a new package following a pattern like NewPackage.Mvc3, like I've seen others do but that doesn't seem very obvious to a user installing it and I only want a slightly different web.config.transform so that's my fallback option.
I don't believe what your describing is possible using the default transform support. You might be able to invoke the transform feature directly from a powershell install script, otherwise you'll have to make the changes manually (and roll them back on your uninstall script).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With