Wix Installer升级和删除文件+注册表项

时间:2015-12-01 22:18:36

标签: wix

我有一个应用程序需要1.在Program Files子文件夹中创建DLL文件(例如C:\ Program Files(x86)\ myapp),以及2.在HKCU中创建一个注册表项。当我运行删除时,我需要删除此子文件夹及其文件,以及注册表项。 当我运行较新版本的安装文件时,我需要新的DLL文件来替换现有的文件。

我一直在努力让它发挥作用,尝试了各种线程和网站的几个提示。 到目前为止,我将删除程序文件,但不删除注册表。我无法让文件升级工作(我为每个新版本更改了UpgradeCode& ProductVersion)

以下是我所拥有的摘录

    <Product Id="$(var.ProductID)"
               Name="myapp"
           Language="1033"
           Version="$(var.ProductVersion)"
           UpgradeCode="$(var.UpgradeCode)"
           Manufacturer="$(var.Manufacturer)">    
    <Package Description="Windows installer for myApp $(var.ProductVersion)"
             Comments="Execute to install myApp $(var.ProductVersion)"
            InstallerVersion="200"
            Compressed="yes" />     
<Media Id="1" Cabinet="contents.cab" EmbedCab="yes" CompressionLevel="high"/>
    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Minimum="$(var.ProductVersion)"
                     OnlyDetect="yes"
                      Property="NEWERVERSIONDETECTED" />
      <UpgradeVersion Minimum="1.0.0.0"
                      IncludeMinimum="yes"
                      Maximum="$(var.ProductVersion)"
                      IncludeMaximum="no"
                      Property="OLDERVERSIONBEINGUPGRADED" />
    </Upgrade>
    <CustomAction Id="UIandAdvertised" Error="Something about the UI."/>
        <Directory Id="TARGETDIR" Name="SourceDir"/>        
        <Feature Id="Complete"
               Title="myApp"
               Description="Installation of myApp $(var.ProductVersion)"
               Level="1">
             <ComponentRef Id="myAppFiles"/>
                 <ComponentRef Id="RegistryEntry"/>
        </Feature>
    <Property Id="WIXUI_INSTALLDIR">INSTALLDIR</Property>
    <UIRef Id="WixUI_InstallDir"/>    
    <InstallExecuteSequence>
      <RemoveExistingProducts Before="InstallInitialize" />
      <RemoveRegistryValues />
    </InstallExecuteSequence>
  </Product>

我的文件和注册信息保存在一个单独的文件中:

<Fragment>
        <DirectoryRef Id="TARGETDIR">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="INSTALLDIR" Name="myapp">
                    <Component Id="myAppFiles" Guid="{xxxx-xxxx-xxxx-xxxx-xxxxxxxx}">
          <File Id="myapp.dll" Name="myapp.dll" KeyPath="yes" Source="..\src\bin\x86\Release\myapp.dll" />
          </Component>
                    <Component Id="RegistryEntry" Guid="{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx}" Win64="no" >
                        <RegistryKey Root="HKCU" Key="Software\myapp" Action="createAndRemoveOnUninstall">
              <RegistryValue Type="string" Value="myapp" />
            </RegistryKey>
                    </Component>
                </Directory>
            </Directory>
        </DirectoryRef>

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

使用产品ID =“*”, 它会更改每个构建的产品ID guid。 但请保持产品的升级代码相同,除非您不想支持升级。

您可以使用主要升级代码而不是升级代码。它更容易使用。

indice_question = 0;

$('#add_question').on('click',function(){

    var template = $("#question_template").html();
    var question_html = "<div id='question_" + indice_question + "'>" + template + "</div>";

    $(question_html).find('input').each(function() {
        $(this).attr('name','question[question'+indice_question+']'+$(this).attr('name'));
        console.log($(this).attr('name'));
    });
	console.log($(question_html).html());

	$('#question_list').append(question_html);
	indice_question++;

});