C# 调试(逐步完成)VS安装项目,您是如何做到的?
我正在调试我在c#(VS)中创建的安装项目。。。我将项目当前设置为“调试”而不是“发布”,并将以下代码添加到我的自定义操作区域C# 调试(逐步完成)VS安装项目,您是如何做到的?,c#,visual-studio-2010,installation,custom-action,C#,Visual Studio 2010,Installation,Custom Action,我正在调试我在c#(VS)中创建的安装项目。。。我将项目当前设置为“调试”而不是“发布”,并将以下代码添加到我的自定义操作区域 public override void Install(System.Collections.IDictionary stateSaver) { if (Debugger.IsAttached == false) Debugger.Launch(); MessageBox.Show("Installing Application...");
public override void Install(System.Collections.IDictionary stateSaver)
{
if (Debugger.IsAttached == false) Debugger.Launch();
MessageBox.Show("Installing Application...");
//Continue with install process
base.Install(stateSaver);
}
//Code to perform at the time of uninstalling application
public override void Uninstall(System.Collections.IDictionary savedState)
{
if (Debugger.IsAttached == false) Debugger.Launch();
MessageBox.Show("Uninstalling Application...");
//Continue with uninstall process
base.Uninstall(savedState);
}
当我去安装时(右键单击setup project->install),它可以按预期工作,我可以使用F11逐步完成每一行。当我转到卸载(右键单击setup project->uninstall)时,它将不允许我逐步使用F11或继续使用F5,也不允许我看到任何intellisense弹出窗口(如变量值等)。尽管我可以单击文件菜单选项来执行每项操作(调试->继续和调试->单步执行)
你知道为什么会出现这种情况,以及我如何获得这种功能吗
附加问题:在运行期间,您是否可以像使用普通程序一样在执行安装项目时更改任何代码(如添加消息框)?解决方案:
在我的例子中,我试图调试我的自定义安装操作install()和Uninstall()。我最终将以下内容添加到我的自定义操作中
if (Debugger.IsAttached == false) Debugger.Launch();
这很简单,下面是一个例子
//Code to perform at the time of installing application
public override void Install(System.Collections.IDictionary stateSaver)
{
if (Debugger.IsAttached == false) Debugger.Launch();
CustomParameters cParams = new CustomParameters();
cParams.Add("InstallPath", this.Context.Parameters["targetdir"]);
cParams.SaveState(stateSaver);
//Continue with install process
base.Install(stateSaver);
}