private static bool NeedRegisterWithCassini(Guid appID, string newWebAppFolder, out int port) { port = 0; WebServer.Metabase mb = WebServer.Metabase.Load(); WebServer.ApplicationEntry appInfo = mb.FindApplication(appID); if (appInfo == null) { // App is not currently registered. return(true); // tell to register it for the first time on any port. } port = appInfo.Port; DirectoryInfo currentDir = new DirectoryInfo(appInfo.PhysicalPath); DirectoryInfo newDir = new DirectoryInfo(newWebAppFolder); if (currentDir.FullName.ToLower() == newDir.FullName.ToLower()) { // app is present and is in the same fodler as before upgrade, // so no need to register. return(false); } // App exists, but was installed into a new fodler, // so it needs to be re-registered, preferrably on the same port as before. return(true); }
public override void Install(System.Collections.IDictionary stateSaver) { int port; if (NeedRegisterWithCassini(webAppID, this.WebAppDir, out port)) { // Register the app with UltiDev Cassini WebServer.ApplicationEntry appInfo = WebServer.Metabase.RegisterApplication(webAppID, appName, port, appDesc, this.WebAppDir, "Default.aspx", false); port = appInfo.Port; } base.Install(stateSaver); // Create app registration file to enable future (re)registrations. this.UpdateHvpnaFile(port); // Register web app with UltiDev HttpVPN Portal. this.RegisterWebAppWithHttpVpn(port); }