私が知っている唯一の方法は、post.buildイベントでカスタムカッシーニ起動を行うことです。このカスタムメイドのプロセスは、カッシーニのすべてのインスタンスを強制終了し、新しいインスタンスを起動します。これを機能させるには、小さなカスタムコマンドラインユーティリティを作成する必要があります。ここではSpawnProcessと呼んでいます。
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Diagnostics;
namespace SpawnProc
{
class Program
{
public static void Main(string[] args)
{
if (args.Length > 0)
{
// Kill all current instances
FileInfo fi = new FileInfo(args[0]);
string name = Path.GetFileNameWithoutExtension(fi.FullName);
foreach (Process proc in Process.GetProcessesByName(name))
{
proc.Kill();
}
ProcessStartInfo startInfo = new ProcessStartInfo(args[0]);
if (args.Length > 1)
{
startInfo.Arguments += "/port:" + args[1];
}
if (args.Length > 2)
{
startInfo.Arguments += " /path:\"" + args[2].Trim(new char[]{'"'}) + "\"";
}
if (args.Length > 3)
{
startInfo.Arguments += " /vpath:\"" + args[3].Trim(new char[]{'"'}) + "\"";
}
try
{
Process.Start(startInfo);
}
catch (Exception ex)
{
Debug.WriteLine("Error: " + ex.Message);
for (int i = 0; i < args.Length; i++)
{
Debug.WriteLine("args[" + i + "]: " + args[i].ToString());
}
}
}
}
}
}
次に、カッシーニを使用しないようにVisualStudioに指示します。Webアプリケーションのプロパティ->Webに移動し、[カスタムWebサーバーを使用する]を選択して、次のように入力しますhttp://localhost:1685/
(または使用するポート番号)。次に、ビルド後のイベントに次のコマンドを入力します。
"$(ProjectDir)..\SpawnProc\bin\debug\SpawnProc" "C:\Program Files (x86)\Common Files\microsoft shared\DevServer\9.0\WebDev.WebServer.exe" 1685 "$(ProjectDir)" /
パスが正しいことを確認してください。たとえば、64ビットOSを実行しているため、プログラムファイルのパスが32ビットOSとは異なります。また、私のSpawnProc.exeはサブプロジェクトにあります。