WiX安装程序MSI未安装使用Visual Studio 2017创建的Winform应用 [英] WiX installer msi not installing the Winform app created with Visual Studio 2017

查看:75
本文介绍了WiX安装程序MSI未安装使用Visual Studio 2017创建的Winform应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个简单的测试,我为一个简单的Winform应用程序创建了一个 Wix 安装程序,如下所示。但是,当我运行使用安装程序创建的 msi 时,它只运行一秒钟,然后退出而未安装Winform应用程序。 问题:这里可能是什么问题?我的 Product.wxs 文件似乎丢失了一些东西。 注意:我正在使用 VS2017

For a simple test I created a Wix installer app for a simple Winform app as follows. But when I run the msi created with the installer it runs for just one second and exits without installing the Winform app. Question: What could be the issue here? It seems something is missing in my Product.wxs file. Note: I'm using VS2017

产生问题的步骤


  1. Wix Toolset Visual Studio 2017 Extension = https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension rel = nofollow noreferrer>此处,并按照他们的指示安装 WiX 3.11 RC2 来自此处

  2. 创建了默认的 Winform项目 [只是一个表单,没有添加任何内容]

  3. 创建了一个 Wix安装项目在同一解决方案中使用 Toolset\v3\S​​etup Project 模板

  4. 在WiX安装项目中添加了对Winform项目的引用

  5. 构建整个解决方案。

  6. 右键单击Setup项目并重新构建它,从而创建了 .msi 文件放在其 \..bin\Debug 中der

  7. 双击步骤6中的 .msi 文件。文件运行了一秒钟,出现了Windows 10安装对话框(显示为询问您是否要安装此程序的任何安装)。我点击了。安装程序再次运行一秒钟,然后退出。但是未安装Winform应用程序。

  1. Installed Wix Toolset Visual Studio 2017 Extension from here and followed their instructions to install WiX 3.11 RC2 from here
  2. Created a default Winform project [just one single form nothing added to it]
  3. Created a Wix Setup project by using Toolset\v3\Setup Project template in the same solution
  4. In WiX Setup project Added a reference to Winform project
  5. Built the entire solution.
  6. Right clicked the Setup project and re-built it that created an .msi file in its \..bin\Debug folder
  7. Double clicked the .msi file from step 6. File ran for one second, windows 10 installation dialog appeared (as it appears for any installation asking you if you want to install this program). I clicked Yes. Installer ran for one second again then exited. But the Winform app was not installed.

默认Product.wxs文件 [我没有在此处添加任何内容除了向 Manufacturer 属性添加值]

Default Product.wxs file [I did not add anything here except for adding a value to Manufacturer attribute]

<?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>


推荐答案

Hello WiX(请使用透明铝)



我认为您需要的是来自CodeProject的WiX的 Hello World 。现在这已经很老了,但仍然擅长向您展示如何编译有效的MSI的基本知识。

"Hello WiX" (transparent aluminum please)

I think what you need is the "Hello World" of WiX from CodeProject. This is quite old now, but still good at showing you the very basics of getting a working MSI compiled.

更新:下面,我添加了有关如何从新的WiX 3 Visual Studio项目中编译MSI的分步说明。

UPDATE: Below I have added a step-by-step description of how to compile an MSI from a fresh WiX 3 Visual Studio project.

这里是另一种答案,其中包含一些上下文信息WiX实际上是: MSI与nuget包:哪种更适合连续交付?。您还将在这里找到指向 hello world的链接,还有其他一些链接。

Here is another answer from way back with some context information for what WiX really is: MSI vs nuget packages: which are is better for continuous delivery?. You will find the link to "hello world" here as well, but also several other links.

总结:检查第一个链接至获得WiX的 hello world。然后,使用几个测试组件更新源代码并重新编译。您应该拥有 Orca (SDK工具)才能查看已编译的MSI文件。由于已安装Visual Studio,请尝试搜索 Orca-x86_zh-cn.msi 并安装(这是Microsoft自己的官方MSI查看器和编辑器)。然后在开始菜单中找到Orca。从技术上讲,Orca是作为Windows SDK(不是Visual Studio)的一部分安装的,但是Windows SDK是与Visual Studio安装捆绑在一起的。拥有已编译的MSI文件后,只需右键单击该文件,然后选择用Orca编辑

In summary: check the first link to get the "hello world" of WiX. Then update your source with a couple of test components and recompile. You should get hold of Orca (SDK tool) to be able to view the compiled MSI files. Since you have Visual Studio installed, try searching for Orca-x86_en-us.msi and install it (this is Microsoft's own, official MSI viewer and editor). Then find Orca in the start menu. Technically Orca is installed as part of Windows SDK (not Visual Studio), but Windows SDK is bundled with the Visual Studio install. Once you have a compiled MSI file, just right click it and select Edit with Orca.

一些经验将是需要这样的文件才真正有意义。本质上,它是存储在COM结构化存储文件(OLE)中的原始MS SQL数据库。本质上,文件中的文件系统具有用于不同内容(例如文件和数据表等)的流。只需将其视为具有正常参照完整性的数据库,并首先关注诸如 File Component 之类的核心表。

Some experience will be needed before such a file really makes sense. In essence it is a primitive MS SQL database stored in a COM structured storage file (OLE). Essentially a file system in a file with streams for different content (such as files, and datatables, etc...). Just think of it as a database with normal referential integrity and focus on the core tables such as File and Component at first.

让我尝试逐步说明如何在新创建的WiX 3项目中使用默认的WiX GUI进行编译。您可以在答案的最后部分看到这些更改合并为完整的示例,但请仔细阅读此步骤,这样才有意义。

Let me try a step-by-step description of what you can do in a freshly made WiX 3 project to make it compile with a default WiX GUI. You can see these changes "merged" into a complete sample in the last section of the answer, but do read this step-by-step so it makes sense.


  1. 创建一个新的WiX3项目。您知道该怎么做,我不会在细节上浪费时间。

  1. Create a new WiX3 project. You know how to do that, I won't waste time with the details.

设置制造商属性为您的公司名称。现在,将您选择的新名称设置为 Name 属性。在此示例中,将其设置为 MinimalTester -请使用其他功能。

Set the Manufacturer attribute to your company name. Now set a new name of your choosing to the Name attribute. In this sample it is set to MinimalTester - use something else please.

更改< MediaTemplate /> < MediaTemplate EmbedCab = yes /> 即可在MSI中使用嵌入式cab文件。这样,仅创建MSI,而没有其他外部CAB文件。

Change <MediaTemplate /> to <MediaTemplate EmbedCab="yes" /> to use embedded cab files in the MSI. This way only the MSI is created and there is no additional, external CAB file.

在MediaTemplate元素之后,直接添加以下内容: < UIRef Id = WixUI_Mondo /> 。这会将默认WiX对话框集添加到您的MSI,因此它具有更通用的功能所需要的基本知识。现在,您可以运行修复和修改,并按照大多数MSI文件从Installshield或Advanced Installer或其他专业工具提供的内容获得向导,以进行原始安装。至关重要的是:您的管理安装将有一个对话框,您可以在其中指定

Directly after the MediaTemplate element, add this: <UIRef Id="WixUI_Mondo" />. This will add a default WiX dialog set to your MSI so it has the basics of what is needed to be more generically useful. You can now run repair, and modify and you get a wizard for the original install along the lines of what most MSI files provide from Installshield or Advanced Installer or other professional tools. And crucially: your administrative installation will have a dialog where you can specify where files should be extracted to.

我们将在WiX设置中添加我们自己的许可协议(否则您将得到一个默默无闻的默认协议)。直接在< UIRef Id = WixUI_Mondo /> 之后,添加此元素:< WixVariable Id = WixUILicenseRtf Value = TestLicenseAgreement.rtf /> 。现在,创建文件 TestLicenseAgreement.rtf 并将其放置在与主WiX源文件相同的文件夹中(快速方法:在Visual Studio中,右键单击项目,然后单击在文件中打开文件夹资源管理器,现在右键单击=>新建=> RTF文件
来创建RTF文件。也许可以打开RTF并输入一些测试文本)。 对话框的进一步自定义(位图等)。

We will add our own License Agreement to the WiX setup (or else you will get an mumbling default one). Directly following <UIRef Id="WixUI_Mondo" /> add this element: <WixVariable Id="WixUILicenseRtf" Value="TestLicenseAgreement.rtf" />. Now create the file TestLicenseAgreement.rtf and place it in the same folder as your main WiX source file (quick way: in Visual Studio, right click project and "Open Folder in File Explorer", now create the RTF file with right click => New => RTF file . And maybe open the RTF and enter some test text). Further customization of the dialogs (bitmaps and more).

WiX对话框集是在dll中定义的,我们需要引用它。在您的Visual Studio WiX项目中:右键单击引用 =>添加参考... =>导航至C:\Program Files(x86)\WiX Toolset v3.11\bin\ 。双击 WixUIExtension.dll ,最后单击 OK

The WiX dialog set is defined in a dll, we need to reference it. In your Visual Studio WiX project: Right click References => Add Reference... => Navigate to C:\Program Files (x86)\WiX Toolset v3.11\bin\. Double click WixUIExtension.dll and finally click OK.

现在在WiX中添加可能的最小最小组件,并将绝对路径指定为源。这是为了确保您可以编译MSI。之后,您可以将路径设为相对路径或变量(暂时将其直接添加到 INSTALLFOLDER 目录元素下):

Now add the absolute minimal component possible in WiX with an absolute path specified as source. This is to be sure you can compile the MSI. Afterwards you can make the path relative or a variable (just add this directly under the INSTALLFOLDER directory element for now):



  <Component Feature="ProductFeature">
    <File Source="C:\Users\someone\SourceControl\MyProject\CoreApp.exe" />
  </Component>




  1. 最后右键单击解决方案中的WiX项目并选择构建。通过右键单击WiX项目并单击在文件资源管理器中打开文件夹,您可以快速测试运行MSI。现在,双击 bin ,然后双击 Debug (或者如果您切换到发行版,则发行版-不确定默认差异)。您应该在对话框序列的第二个对话框中看到自己的许可协议。

  1. Finally right click the WiX project in your solution and select Build. And you can quickly test run the MSI by right clicking the WiX project and clicking Open Folder in File Explorer. Now double click on bin and then Debug (or Release if you switched to a release build - not sure what "default differences" are between the two configurations). You should see your own license agreement in the second dialog in the dialog sequence.

以后的WiX版本具有非常好的默认属性,即几乎总是设置为模板值,或者其中两个属性本质上是多余的。只需将它们放在您的源代码之外,然后让WiX编译器为它们添加默认值即可。

The later WiX versions have great defaults for attributes that are almost always set to "template values" or where two attributes essentially are redundant. Just leave them out of your source and let the WiX compiler add them with default values. Much less fuss.

例如:上述元素缺少组件ID 。在编译期间,它默认为其包含的File元素的ID。反过来, File元素ID 也丢失了,默认为 Source属性指定的文件名(是必填属性。)

As an example: The above element lacks a Component Id. During compilation it defaults to the Id of the File element it contains. The File element Id in turn, is also missing and will default to the file name specified by the Source attribute (which is a mandatory attribute).

也许可以看一下下面的答案以获得更详细的说明和底部的具体示例: WIX中Guid的语法? 看看一旦消除了所有问题,WiX源文件将变得多么简单。某些属性的冗余和重复?更少的文字,更少的错误。

Maybe look at this answer for a longer description and a concrete example towards the bottom: Syntax for guids in WIX? See how simple your WiX source files can be once you eliminate all the redundancy and duplication of certain attributes? Less text, less bugs.

在下面的示例中,组件已移动到默认的ComponentGroup中-因此,无需指定其所属的功能(与上面不同)。

In the below sample the component has been moved into the default ComponentGroup - hence there is no need to specify what feature it belongs to (unlike above).

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <!--CHANGE 0: Set Manufacturer attribute to something, you must also specify a full GUID for UpgradeCode -->
  <Product Id="*" Name="MinimalTester" Language="1033" Version="1.0.0.0" Manufacturer="My Company" UpgradeCode="PUT-GUID-HERE">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <!--Standard: <MediaTemplate />-->
    <!--CHANGE #1: Enable embedded cab files, so there is only one file generated, the MSI file -->
    <MediaTemplate EmbedCab="yes" /> 

    <!--CHANGE #2: Add the following elements to link one of the default WiX GUI sequences and show the specified license agreement. The RTF file must be created and placed next to your WiX source file -->
    <UIRef Id="WixUI_Mondo" /> 
    <WixVariable Id="WixUILicenseRtf" Value="TestLicenseAgreement.rtf" />        

    <!--CHANGE #3: Add WiX dll reference. In Visual Studio WiX project: Right click References => Add Reference... => Navigate to C:\Program Files (x86)\WiX Toolset v3.11\bin\. Double click WixUIExtension.dll. Click OK -->

    <Feature Id="ProductFeature" Title="MinimalTester" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="MinimalTester" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

      <!--CHANGE #4: Remove TODO elements, add the most basic component possible as illustrated below -->
      <Component>
        <File Source="C:\Users\someone\SourceControl\MyProject\CoreApp.exe" />
      </Component>

    </ComponentGroup>
  </Fragment>
</Wix>

尝试编译和测试安装。应该在正常系统上安装到 C:\Program Files(x86)\MinimalTester

Try to compile and test install. Should install to C:\Program Files (x86)\MinimalTester on a normal system.

也许以下是WiX教程的更多链接: WIX安装程序未正确显示WixUI对话框的自定义图像

Maybe see further links for WiX tutorials here: WIX Installer not displaying the custom image of WixUI Dialog correctly.

这篇关于WiX安装程序MSI未安装使用Visual Studio 2017创建的Winform应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆