IISのWeb展開 - 仮想ディレクトリを作成しますか?
-
26-09-2019 - |
質問
VS2010のサイトを開発する際に/私はdevのサイトのサーバーに自分のマシンからサイトを公開するWeb配置を使用しています、IIS 7.5を。
サイトが約40仮想ディレクトリを持っている、と私は自動的に展開中のサーバー上のものを作成したいと思います。これを実行するための簡単な方法はありますか?
私は、ファイルやデータベースからリストをロードし、必要に応じてそれらを作成することになり、小さなアプリケーションを書いて検討しています。ディレクトリは作品にレンチをスローしており、また、Webサーバ上よりも私の開発マシン上の異なる物理パスを持っています。
解決
あなたのWeb展開のためのMSBuildを使用している場合は、
あなたはあなたの仮想ディレクトリを作成するために使用することができます.NETでCustomBuildTaskを書くことができます。
私はカスタムビルドタスクを使用して仮想ディレクトリを作成するために使用するコードがあり、カスタムビルドタスクを作成し、消費する方法についての多くのリソースがありますが、ここにあります
public void CreateVirtualDirectory()
{
DirectoryEntry oDE = new DirectoryEntry("IIS://" +
this._strServerName + "/W3SVC/" + _webSiteID + "/Root");
//Get Default Web Site
DirectoryEntries oDC = oDE.Children;
//Add row to schema
DirectoryEntry oVirDir = oDC.Add(this._strVDirName,
oDE.SchemaClassName.ToString());
//Commit changes for Schema class File
oVirDir.CommitChanges();
//Set virtual directory to physical path
oVirDir.Properties["Path"].Value = this._strPhysicalPath;
//Set read access
oVirDir.Properties["AccessRead"][0] = true;
//Set the default docs
oVirDir.Properties["EnableDefaultDoc"][0] = true;
oVirDir.Properties["DefaultDoc"][0] = "default.aspx";
//set the name
oVirDir.Properties["AppFriendlyName"][0] = this._strVDirName;
//do it
oVirDir.Invoke("AppCreate", true);
//set the application pool
if (!string.IsNullOrEmpty(_strApplicationPool))
{
object[] param = { 0, _strApplicationPool, true };
oVirDir.Invoke("AppCreate3", param);
oVirDir.Properties["AppIsolated"][0] = "2";
}
//Save all the changes
oVirDir.CommitChanges();
}
他のヒント
私はWebDeployに対する任意のカスタムプログラミングを行っていませんでしたが、私はそれのためのAPIがあることを言及を見てきました。私はそれに公式ドキュメントを見つけるように見えることはできませんが、おそらく、このブログ+サンプルアプリが起動提供することができます:<のhref = "http://blogs.iis.net/moshaikh/archive/2010/03/08/webを-deploy-API-ウェブapplication.aspx」のrel = "nofollowを"> Web配置API Webアプリケーションの
所属していません StackOverflow