我正在为我公司的MVC4模板构建nuget包。我遇到了我需要的Global.asax.cs
进行修改,以添加这两条线的一个问题:Nuget PowerShell脚本修改Global.asax.cs
using System.Web.Optimization;
顶部,命名空间之前和
BundleConfig.RegisterBundles(BundleTable.Bundles);
在Application_Start()
方法
我试着在里面创建一个Global.asax.cs.pp
和namespace $rootnamespace$
,但这似乎不起作用。看来Nuget不会覆盖现有的文件?
我认为最后一个选择是编写一个powershell脚本(Install.ps1
?)来执行此操作。这里是我的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>
我的问题是2倍,1)我做错了什么,我.nuspec? 2)如果使用.pp修改Global.asax
不是一个选项,那么当我将这个nuget添加到项目中时,我需要写的powershell脚本是否会自动运行,并且是否需要执行任何操作特别为它运行(阅读文档似乎只需将Install.ps1
在tools\
会做)?
我们如何将文本附加到文档的末尾 – ppoliani