Browse Source

Fix creating applications/virtual directory.

pull/23/head
Eusebiu Marcu 15 years ago
parent
commit
1cc53f1885
  1. 11
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
  2. 37
      src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs

11
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs

@ -45,10 +45,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
} }
break; break;
case WebServer.IIS: case WebServer.IIS:
if (WebProjectService.IISVersion == IISVersion.IIS5 || if (WebProjectService.IISVersion != IISVersion.IISExpress &&
WebProjectService.IISVersion == IISVersion.IIS6 || WebProjectService.IISVersion != IISVersion.None) {
WebProjectService.IISVersion == IISVersion.IIS7 ||
WebProjectService.IISVersion == IISVersion.IIS_Future) {
UseLocalIIS.IsChecked = true; UseLocalIIS.IsChecked = true;
ProjectUrl.Text = CurrentProjectDebugData.ProjectUrl ?? string.Empty; ProjectUrl.Text = CurrentProjectDebugData.ProjectUrl ?? string.Empty;
@ -134,9 +132,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
WebProjectDebugData data = new WebProjectDebugData(); WebProjectDebugData data = new WebProjectDebugData();
data.WebServer = WebServer.IIS; data.WebServer = WebServer.IIS;
data.Port = string.Empty; data.Port = string.Empty;
bool isIISInstalled = WebProjectService.IISVersion == IISVersion.IIS5 || bool isIISInstalled = WebProjectService.IISVersion != IISVersion.IISExpress &&
WebProjectService.IISVersion == IISVersion.IIS6 || WebProjectService.IISVersion != IISVersion.None;
WebProjectService.IISVersion == IISVersion.IIS7;
if (!isIISInstalled) { if (!isIISInstalled) {
StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound"); StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");

37
src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs

@ -7,6 +7,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using Microsoft.Win32; using Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Project namespace ICSharpCode.SharpDevelop.Project
@ -14,11 +15,12 @@ namespace ICSharpCode.SharpDevelop.Project
public enum IISVersion public enum IISVersion
{ {
None = 0, None = 0,
IISExpress,
IIS5 = 5, IIS5 = 5,
IIS6, IIS6,
IIS7, IIS7,
IISExpress, IIS8,
IIS_Future IIS_Future = 100
} }
public enum WebServer public enum WebServer
@ -49,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary> /// <summary>
/// Gets &quot;iisexpress&quot; string. /// Gets &quot;iisexpress&quot; string.
/// </summary> /// </summary>
public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress"; public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress";
/// <summary> /// <summary>
/// Gets &quot;aspnet_wp&quot; string. /// Gets &quot;aspnet_wp&quot; string.
@ -193,8 +195,9 @@ namespace ICSharpCode.SharpDevelop.Project
public static string CreateVirtualDirectory(string virtualDirectoryName, string physicalDirectoryPath) public static string CreateVirtualDirectory(string virtualDirectoryName, string physicalDirectoryPath)
{ {
try { try {
string iisNotFoundError = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
if (!IsIISInstalled) if (!IsIISInstalled)
return ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound"); return iisNotFoundError;
string error; string error;
@ -208,20 +211,26 @@ namespace ICSharpCode.SharpDevelop.Project
virtualDirectoryName, virtualDirectoryName,
out error); out error);
break; break;
case IISVersion.None:
return iisNotFoundError;
default: default:
// TODO: find a better way to create IIS 7 applications without Microsoft.Web.Administration.ServerManager // TODO: find a better way to create IIS applications without Microsoft.Web.Administration.ServerManager
string name = "/" + virtualDirectoryName; string name = "/" + virtualDirectoryName;
// load from GAC - IIS7 is installed // load from GAC
Assembly webAdministrationAssembly; Assembly webAdministrationAssembly = null;
try { try {
// iis 7 // iis installed
webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); foreach(var assembly in GacInterop.GetAssemblyList()) {
} if (assembly.FullName.Contains("Microsoft.Web.Administration")) {
catch { webAdministrationAssembly = Assembly.Load(assembly.FullName);
// iis express break;
webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); }
}
} catch {
return iisNotFoundError;
} }
if (webAdministrationAssembly == null)
return iisNotFoundError;
// use dynamic because classic reflection is way TOO ugly // use dynamic because classic reflection is way TOO ugly
dynamic manager = webAdministrationAssembly.CreateInstance("Microsoft.Web.Administration.ServerManager"); dynamic manager = webAdministrationAssembly.CreateInstance("Microsoft.Web.Administration.ServerManager");

Loading…
Cancel
Save