I need to deploy my web service. It needs to run in a separate application pool in IIS with its own credentials.
我需要部署我的Web服务。它需要使用自己的凭据在IIS中的单独应用程序池中运行。
Is it possible to do this by using a Web Setup Project in VS 2008?
是否可以通过在VS 2008中使用Web安装项目来实现此目的?
By default, I seem to only be able to choose an existing application pool.
默认情况下,我似乎只能选择现有的应用程序池。
2 个解决方案
#1
7
I've been down this road before and unfortunately you'll need to create the application pool manually or write a Custom Action to manage this for you.
我以前一直在这条路上,不幸的是你需要手动创建应用程序池或编写自定义操作来为你管理。
Further to Grzenio's question in the comments below:
在下面的评论中继续Grzenio的问题:
"Could you give me a hint where to start looking for the code/helper classes? And do you keep your project a Web Setup Project, or just use the standard application setup project?"
“你能给我一个提示,从哪里开始寻找代码/帮助程序类?你是否将项目保持为Web安装项目,或者只使用标准的应用程序安装项目?”
I added a new project called InstallHelper
to the solution containing the setup project. In that project I created a class called InstallActions
which derives from:
我在包含安装项目的解决方案中添加了一个名为InstallHelper的新项目。在那个项目中,我创建了一个名为InstallActions的类,它来自:
System.Configuration.Install.Installer
(MSDN).
System.Configuration.Install.Installer(MSDN)。
There are four methods you can override on the Installer
base class to allow you to specify custom actions depending on whether you're in the Install, Commit, Uninstall or Rollback phases when the installer is running.
您可以在Installer基类上覆盖四种方法,以允许您根据安装程序运行时是处于“安装”,“提交”,“卸载”还是“回滚”阶段来指定自定义操作。
I also added a number of text box dialogues to the setup project user interface. Input and state captured from these dialogues is passed to your custom install action via a dictionary. i.e.:
我还在安装项目用户界面中添加了许多文本框对话框。从这些对话中捕获的输入和状态将通过字典传递到您的自定义安装操作。即:
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration.Install;
using System.Windows.Forms;
namespace InstallHelper
{
[RunInstaller(true)]
public partial class PostInstallActions : Installer
{
public override void Install(IDictionary state)
{
base.Install(state);
// Do my custom install actions
}
public override void Commit(IDictionary state)
{
base.Commit(state);
// Do my custom commit actions
}
public override void Uninstall(IDictionary state)
{
base.Uninstall(state);
// Do my custom uninstall actions
}
public override void Rollback(IDictionary state)
{
base.Uninstall(state);
// Do my custom rollback actions
}
}
}
To add your custom action project to the setup project, open the Custom Actions viewer/editor and specify the output from the InstallHelper
project.
要将自定义操作项目添加到安装项目,请打开“自定义操作”查看器/编辑器并指定InstallHelper项目的输出。
That's the basics and should get you started. The Web Setup Project also supports custom actions and additional user input dialogue boxes, so you may wish to re-use your existing project, in addition to a custom action.
这是基础,应该让你开始。 Web Setup Project还支持自定义操作和其他用户输入对话框,因此除了自定义操作之外,您可能还希望重新使用现有项目。
#2
11
Check out this post http://forums.iis.net/t/1061734.aspx, it will give some rough idea about Microsoft.Web.Administration dll.
看看这篇文章http://forums.iis.net/t/1061734.aspx,它会给出一些关于Microsoft.Web.Administration dll的粗略概念。
I have not studied the whole concept but I figured how to create new pool and how to attach with new web site / virtual directory.
我还没有研究过整个概念,但我想到了如何创建新池以及如何附加新的网站/虚拟目录。
Creating Application Pool
创建应用程序池
Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
manager.ApplicationPools.Add("NewApplicationPool");
manager.CommitChanges();
Attaching with existing virtual directory
使用现有虚拟目录进行附加
Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];
// defaultSite.Applications will give you the list of 'this' web site reference and all
// virtual directories inside it -- 0 index is web site itself.
Microsoft.Web.Administration.Application oVDir = defaultSite.Applications["/myApp"];
oVDir.ApplicationPoolName = "NewApplicationPool";
manager.CommitChanges();
This way you can assign application pool to your new website using the custom actions, overriding the commit method of installer class.
这样,您可以使用自定义操作将应用程序池分配给新网站,从而覆盖安装程序类的提交方法。
If still find yourself struggling, please let me know and I'll try to send the code.
如果仍然发现自己挣扎,请告诉我,我会尝试发送代码。
Regards Faiyaz faiyazkhan@hotmail.com
关心Faiyaz faiyazkhan@hotmail.com
#1
7
I've been down this road before and unfortunately you'll need to create the application pool manually or write a Custom Action to manage this for you.
我以前一直在这条路上,不幸的是你需要手动创建应用程序池或编写自定义操作来为你管理。
Further to Grzenio's question in the comments below:
在下面的评论中继续Grzenio的问题:
"Could you give me a hint where to start looking for the code/helper classes? And do you keep your project a Web Setup Project, or just use the standard application setup project?"
“你能给我一个提示,从哪里开始寻找代码/帮助程序类?你是否将项目保持为Web安装项目,或者只使用标准的应用程序安装项目?”
I added a new project called InstallHelper
to the solution containing the setup project. In that project I created a class called InstallActions
which derives from:
我在包含安装项目的解决方案中添加了一个名为InstallHelper的新项目。在那个项目中,我创建了一个名为InstallActions的类,它来自:
System.Configuration.Install.Installer
(MSDN).
System.Configuration.Install.Installer(MSDN)。
There are four methods you can override on the Installer
base class to allow you to specify custom actions depending on whether you're in the Install, Commit, Uninstall or Rollback phases when the installer is running.
您可以在Installer基类上覆盖四种方法,以允许您根据安装程序运行时是处于“安装”,“提交”,“卸载”还是“回滚”阶段来指定自定义操作。
I also added a number of text box dialogues to the setup project user interface. Input and state captured from these dialogues is passed to your custom install action via a dictionary. i.e.:
我还在安装项目用户界面中添加了许多文本框对话框。从这些对话中捕获的输入和状态将通过字典传递到您的自定义安装操作。即:
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration.Install;
using System.Windows.Forms;
namespace InstallHelper
{
[RunInstaller(true)]
public partial class PostInstallActions : Installer
{
public override void Install(IDictionary state)
{
base.Install(state);
// Do my custom install actions
}
public override void Commit(IDictionary state)
{
base.Commit(state);
// Do my custom commit actions
}
public override void Uninstall(IDictionary state)
{
base.Uninstall(state);
// Do my custom uninstall actions
}
public override void Rollback(IDictionary state)
{
base.Uninstall(state);
// Do my custom rollback actions
}
}
}
To add your custom action project to the setup project, open the Custom Actions viewer/editor and specify the output from the InstallHelper
project.
要将自定义操作项目添加到安装项目,请打开“自定义操作”查看器/编辑器并指定InstallHelper项目的输出。
That's the basics and should get you started. The Web Setup Project also supports custom actions and additional user input dialogue boxes, so you may wish to re-use your existing project, in addition to a custom action.
这是基础,应该让你开始。 Web Setup Project还支持自定义操作和其他用户输入对话框,因此除了自定义操作之外,您可能还希望重新使用现有项目。
#2
11
Check out this post http://forums.iis.net/t/1061734.aspx, it will give some rough idea about Microsoft.Web.Administration dll.
看看这篇文章http://forums.iis.net/t/1061734.aspx,它会给出一些关于Microsoft.Web.Administration dll的粗略概念。
I have not studied the whole concept but I figured how to create new pool and how to attach with new web site / virtual directory.
我还没有研究过整个概念,但我想到了如何创建新池以及如何附加新的网站/虚拟目录。
Creating Application Pool
创建应用程序池
Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
manager.ApplicationPools.Add("NewApplicationPool");
manager.CommitChanges();
Attaching with existing virtual directory
使用现有虚拟目录进行附加
Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];
// defaultSite.Applications will give you the list of 'this' web site reference and all
// virtual directories inside it -- 0 index is web site itself.
Microsoft.Web.Administration.Application oVDir = defaultSite.Applications["/myApp"];
oVDir.ApplicationPoolName = "NewApplicationPool";
manager.CommitChanges();
This way you can assign application pool to your new website using the custom actions, overriding the commit method of installer class.
这样,您可以使用自定义操作将应用程序池分配给新网站,从而覆盖安装程序类的提交方法。
If still find yourself struggling, please let me know and I'll try to send the code.
如果仍然发现自己挣扎,请告诉我,我会尝试发送代码。
Regards Faiyaz faiyazkhan@hotmail.com
关心Faiyaz faiyazkhan@hotmail.com