The only way I know is to create a custom Cassini start in the post.build event. This custom-made process kills all instances of Cassini and launches a new one. For this to work, you will need to create a small command line utility. I called it SpawnProcess here.
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()); } } } } } }
Then you should instruct Visual Studio not to use Cassini. Get properties for your web application -> Web and select "Use a custom web server", enter something like: http://localhost:1685/ (or any port number that you would like to use). Then enter this command in the event after the build:
"$(ProjectDir)..\SpawnProc\bin\debug\SpawnProc" "C:\Program Files (x86)\Common Files\microsoft shared\DevServer\9.0\WebDev.WebServer.exe" 1685 "$(ProjectDir)" /
Make sure your paths are correct, for example, since I am running a 64-bit OS, my path to the program files is different from the 32-bit OS. In addition, my SpawnProc.exe is located in a subproject.
Magnus Johansson May 20, '09 at 13:19 2009-05-20 13:19
source share