I am creating a nuget package for my company MVC2 template. I ran into a problem when I need to modify Global.asax.cs to add these two lines:
using System.Web.Optimization;
above, in front of the namespace and
BundleConfig.RegisterBundles(BundleTable.Bundles);
at the end of the Application_Start() method
I tried creating Global.asax.cs.pp with namespace $rootnamespace$ inside it, but this does not work. Nuget won't seem to overwrite existing files?
My last option, as I see it, is to write a powershell script ( Install.ps1 ?) For this. Here is my template.nuspec
<?xml version="1.0" encoding="utf-8"?> <package> <metadata> <id>Template.MVC4</id> <version>1.5</version> <title>MVC4 Template</title> <description>Installs and configures files for MVC 4 application template.</description> <authors>Me</authors> <language>en-US</language> <dependencies> <dependency id="Microsoft.AspNet.Web.Optimization" /> </dependencies> <iconUrl>http://www.someurl.com/Logo.jpg</iconUrl> </metadata> <files> <file src="Template\Helpers\*" target="content\Helpers\" /> <file src="Template\Content\*.css" target="content\Content\" /> <file src="Template\Content\animGif\*" target="content\Content\animGif\" /> <file src="Template\Content\custom-theme\*" target="content\Content\custom-theme\" /> <file src="Template\Content\templateImages\*" target="content\Content\templateImages\" /> <file src="Template\Scripts\*" target="content\Scripts\" /> <file src="Template\Views\Shared\*" target="content\Views\Shared\" /> <file src="Template\Views\Home\*" target="content\Views\Home\" /> <file src="Template\Views\_ViewStart.cshtml" target="content\Views\" /> <file src="NuGetPackage\App_Start\*" target="content\App_Start\" /> <file src="NuGetPackage\Controllers\*" target="content\Controllers\" /> <file src="NuGetPackage\Helpers\*" target="content\Helpers\" /> <file src="NuGetPackage\Models\*" target="content\Models\" /> <file src="NuGetPackage\Views\*" target="content\Views\" /> <file src="NuGetPackage\*" target="content\" /> </files> </package>
My question is 2 times, 1) Am I doing something wrong in my .nuspec? and 2) if modifying Global.asax with .pp is not an option, then what is a powershell script that I will need to write so that this run automatically when this nuget is added to the project, and I need to do something special for it launch (reading documents seems to be just placing Install.ps1 in tools\ )?
source share