简体   繁体   English

如何为 .NET 项目创建自定义 Wix 安装程序?

[英]How to create a custom Wix Installer for a .NET project?

I need to create a Wix Installer, that will allow me to have a dialog, where the user can type in a serial number, then I need to save the serial number they entered into the Windows registry.我需要创建一个 Wix 安装程序,这将允许我有一个对话框,用户可以在其中输入序列号,然后我需要将他们输入的序列号保存到 Windows 注册表中。

Also, if they don't enter a serial number, the next button needs to be disabled, so that they cannot proceed with the installation, if they do not enter a serial number.此外,如果他们没有输入序列号,则需要禁用下一步按钮,这样他们就无法继续安装,如果他们没有输入序列号。

WIX does not support key events like the one you want the next button must be enabled when the user enters the key. WIX 不支持按键事件,例如您希望在用户输入按键时必须启用下一步按钮。 Best option is to provide the next button and call a custom action to check whether the key is correct, if un-correct throw error message.最好的选择是提供下一步按钮并调用自定义操作来检查密钥是否正确,如果不正确则抛出错误消息。

<Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
  <Control Id="OrganizationLabel" Type="Text" X="45" Y="80" Width="100" Height="15" TabSkip="no" Text="&amp;Organization:" />
  <Control Id="OrganizationEdit" Type="Edit" X="45" Y="95" Width="220" Height="18" Property="COMPANYNAME" Text="{80}" />
  <Control Id="CDKeyLabel" Type="Text" X="45" Y="125" Width="50" Height="10" TabSkip="no">
    <Text>License &amp;Key:</Text>
  </Control>
  <Control Id="CDKeyEdit" Type="MaskedEdit" X="45" Y="140" Width="250" Height="16" Property="PIDKEY" Text="[PIDTemplate]" />

  <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
    <Publish Event="NewDialog" Value="[WixUI_UserRegistrationDlg_Back]">1</Publish>
  </Control>

  <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
    <Publish Event="ValidateProductID" Value="0">0</Publish>
    <Publish Event="DoAction" Value="CheckingPID">1</Publish>
    <Publish Event="SpawnDialog" Value="InvalidPidDlg">PIDACCEPTED = "0"</Publish>
    <Publish Event="NewDialog" Value="[WixUI_UserRegistrationDlg_Next]">PIDACCEPTED = "1"</Publish>
  </Control>

  <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
    <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
  </Control>
</Dialog>

<Dialog Id="InvalidPidDlg" Width="260" Height="85" Title="[ProductName] [Setup]" NoMinimize="yes">
  <Control Id="Return" Type="PushButton" X="100" Y="57" Width="56" Height="17" Default="yes" Cancel="yes" Text="Ok">
    <Publish Event="EndDialog" Value="Return">1</Publish>
  </Control>
  <Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="30" TabSkip="no">
    <Text>[USERERRMSG]</Text>
  </Control>
</Dialog>

InvlaidPidDlg will show error message. InvlaidPidDlg 将显示错误信息。 From custom action you need to set the value of 'USERERRMSG'从自定义操作中,您需要设置“USERERRMSG”的值

Take a look at this post which explains how you can create customized dialog in Wix based installer看看这篇文章,它解释了如何在基于 Wix 的安装程序中创建自定义对话框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM