会社の MVC4 テンプレート用の nuget パッケージを作成しています。Global.asax.cs
次の 2 行を追加するために を変更する必要があるという問題に遭遇しました。
using System.Web.Optimization;
上部の名前空間の前と
BundleConfig.RegisterBundles(BundleTable.Bundles);
Application_Start()
メソッドの最後に
Global.asax.cs.pp
その中にwithを作成しようとしました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 で aGlobal.asax
を変更することができない場合、この nuget がプロジェクトに追加されたときにこれを自動的に実行するために作成する必要のある powershell スクリプトは何ですか? また、何か特別なことをする必要がありますか?それを実行するには(ドキュメントを読むだけでよいようInstall.ps1
ですtools\
)?