我的解决方案中有 2 个项目
Windows 服务
它的安装项目
我需要我ProjectInstaller : System.Configuration.Install.Installer
的称为 OnAfterInstall 的方法ProductName
从安装项目中获取。我怎么做?
我的解决方案中有 2 个项目
Windows 服务
它的安装项目
我需要我ProjectInstaller : System.Configuration.Install.Installer
的称为 OnAfterInstall 的方法ProductName
从安装项目中获取。我怎么做?
在您的设置项目中,右键单击项目并选择查看 > 自定义操作。添加自定义操作。现在选择 Add Output,选择您的 Web 服务项目,然后单击 OK。
现在选择您的自定义操作并将CustomActionData
属性设置为包含类似的内容/ProductName=[PRODUCTNAME] /whateveryouwant=[Whateveryouwant]
(请注意,这些是键值对;即访问产品名称,ProductName
键是键,值是PRODUCTNAME
)。
请注意,它CustomActionData
包含将传递给您的安装程序类的参数。这PRODUCTNAME
是与用户界面对话框中的输入控件关联的属性名称,因此在您的情况下,您将在您的安装程序中提示用户输入产品名称。所以标签是“产品名称”,对应的属性应该设置为PRODUCTNAME
(显然你可以改变这个,但最重要的是要注意UI属性名称必须与CustomActionData
该示例中的属性名称相同)去工作。
现在在您的安装程序类中,您可以通过以下方式获取产品名称
public override void Install(IDictionary stateSaver)
{
// If you need to debug this installer class, uncomment the line below
//System.Diagnostics.Debugger.Break();
string productName = Context.Parameters["ProductName"].Trim();
string whateveryouwant = Context.Parameters["whateveryouwant"].Trim();
}
请注意,我包含了//System.Diagnostics.Debugger.Break();
您可以评论的注释代码,以便您可以调试安装程序类。
希望这可以帮助。