【发布时间】:2018-06-06 19:59:57
【问题描述】:
为了一个简单的测试,我为一个简单的 Winform 应用程序创建了一个 Wix 安装程序应用程序,如下所示。但是当我运行使用安装程序创建的msi 时,它只运行一秒钟并退出而不安装 Winform 应用程序。 问题:这可能是什么问题?我的Product.wxs 文件中似乎缺少某些内容。 注意:我使用的是VS2017
产生问题的步骤
- 从here 安装
Wix Toolset Visual Studio 2017 Extension并按照他们的说明从here 安装WiX 3.11 RC2 - 创建了一个默认的
Winform project[只有一个表单,没有添加任何内容] - 在同一解决方案中使用
Toolset\v3\Setup Project模板创建了Wix Setup project - 在 WiX 安装项目中添加了对 Winform 项目的引用
- 构建整个解决方案。
- 右键单击 Setup 项目并重新构建它,在其
\..bin\Debug文件夹中创建了一个.msi文件 - 双击第 6 步中的
.msi文件。文件运行了一秒钟,出现了 Windows 10 安装对话框(因为它出现在任何询问您是否要安装此程序的安装中)。我点击了Yes。安装程序再次运行一秒钟然后退出。但未安装 Winform 应用。
默认 Product.wxs 文件 [我这里除了给Manufacturer 属性添加一个值外没有添加任何东西]
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="WiX_test_4_Winfrm" UpgradeCode="e69fe67b-5c28-4764-8196-a6613b840eff">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
</ComponentGroup>
</Fragment>
</Wix>
【问题讨论】:
-
您可以尝试更新 ComponentGroup 以包含 TODO 评论中所说的一些组件吗?您现在似乎没有安装任何文件。
-
@DylanMusil 根据您的建议,我在
ComponentGroup标签中添加了以下内容,但仍然是同样的问题:<Component Id="CMP_SetupProject1"> <File Id="File_WIX_WinfrmTest.exe" Source="$(var.WIX_WinfrmTest.TargetPath)" KeyPath="yes" /> </Component>。我同意你的观点,我在这个项目中遗漏了一些东西。 -
@DylanMusil 实际上你的建议确实有效。在我运行
.msi' exe (as explained in step 6 of my post) the Winform app was installed but it was insie theC:\Program Files (x86)\SetupProject1` 之后,我在StartMenu中寻找它 - 但只有在您向WiX添加高级 UI 功能时,应用才会出现在StartMenu中安装程序,我还没有做的事情。
标签: c# winforms wix windows-installer visual-studio-2017