C#项目发布配置Product.wxs

本文介绍了如何使用WiX工具集来发布C#项目,特别是通过配置Product.wxs文件来实现。内容包括设置产品信息、安装目录、安装序列、自定义动作、启动菜单快捷方式、桌面快捷方式、程序图标、.NET Framework依赖检查等。配置文件中使用了$(var.OutputDir)和$(var.SourceCodeDir)作为变量,确保在编译不同架构时正确打包。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过Wix来发布C#项目还是很方便,主要是通过配置product.wxs,如果是编译模式不同x86和x64位,可以分两个不同的项目分别进行打包。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
  <?include "config.wxi"?>
  <!--工程基本信息-->
  <Product Id="*" Name="iEagle" Language="2052" Version="!(bind.fileVersion.iEagle.exe)" Manufacturer="SRC" UpgradeCode="B70B8F0F-48E1-4149-AD58-636704EA8215">
    <Package InstallerVersion="405" Compressed="yes" InstallScope="perMachine" Manufacturer="SRC" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of iEagle is already installed." AllowDowngrades="no" />
    <MediaTemplate EmbedCab="yes" />
    
    <Binary Id="WixCA.CA.dll" src="..\WixCA\bin\$(var.Configuration)\WixCA.CA.dll" />
    <Property Id='CONFIGFILELOCATION' Value='[SourceDir]' />   
    <CustomAction Id="SetProperty" Execute="immediate"
                        Property="CA_myCustomAction"
                        Value="InstallDir=[MergeRedirectFolder];SourceDir=[CONFIGFILELOCATION]" />
    <CustomAction Id="CA_myCustomAction"
        BinaryKey="WixCA.CA.dll"
        DllEntry="CopyCustomisationFiles"
        Execute="deferred" Impersonate="no"
        Return="check" />

    <InstallExecuteSequence>
      <Custom Action="SetProperty" After="CreateFolders">Not Installed</Custom>
      <Custom Action="CA_myCustomAction" Before="InstallFinalize">Not Installed</Custom>
    </InstallExecuteSequence>
 
    <Feature Id="ProductFeature" Title="iEagle" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentGroupRef Id="FFMPEG" />
      <ComponentGroupRef Id="XML" />
      <ComponentGroupRef Id="ispyserver" />
      <ComponentGroupRef Id="backgrounds" />
      <ComponentGroupRef Id="plugins" />
      <ComponentGroupRef Id="sounds" />
      <ComponentGroupRef Id="Person" />
      <ComponentGroupRef Id="Photo" />
      <ComponentGroupRef Id="webserverroot" />
      <ComponentGroupRef Id="masks" />
      <ComponentGroupRef Id="data" />
      <ComponentGroupRef Id="api" />
      <ComponentGroupRef Id="commands" />
      <ComponentGroupRef Id="audio" />
      <ComponentGroupRef Id="video" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />      
    </Feature>
    <Feature Id="VCRedist" Title="Visual C++ 10.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
      <MergeRef Id="VCRedist" />
    </Feature>

    <WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\license.rtf" />
    <WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\banner.bmp" />
    <WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\dialog.bmp" />
    <UI>
      <UIRef Id="WixUI_InstallDir" />
      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2">1</Publish>
      <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">1</Publish>
      <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch iEagle" />
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
    <Property Id="WixShellExecTarget" Value="[#iEagle.exe]" />
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
    <PropertyRef Id="WIX_IS_NETFRAMEWORK_45_OR_LATER_INSTALLED" />
    <!--NET Framework 安装校验,需要 WixUIExtension.dll-->
    <Condition Message="This application requires .NET Framework 4.5. Please install the .NET Framework then run this installer again.">
      <![CDATA[Installed OR WIX_IS_NETFRAMEWORK_45_OR_LATER_INSTALLED]]>
    </Condition>
    <!--程序图标-->
    <Icon Id="iEagle.ico" SourceFile="$(var.OutputDir)\iEagle.ico" />
    <Property Id="ARPPRODUCTICON" Value="icon.ico" />
  </Product>
  <!-- 安装目录结构-->
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="iEagle" /><!--iEaglePro-->
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop"></Directory>
      <Directory Id="ProgramFilesFolder">
        <Directory Id="ParentFolder" Name="iEagle"><!--iEaglePro-->
          <Directory Id="INSTALLFOLDER" Name="iEagle"><!--iEaglePro-->
            <Directory Id="XML" Name="XML" />
            <Directory Id="WebServerRoot" Name="WebServerRoot">
              <Directory Id="Data" Name="data" />
              <Directory Id="api" Name="api">
                <Directory Id="Sources" Name="sources">
                  <Directory Id="audio" Name="audio" />
                  <Directory Id="video" Name="video" />
                </Directory>
              </Directory>
            </Directory>
            <Directory Id="Sounds" Name="Sounds" /> 
            <Directory Id="Plugins" Name="Plugins" />
            <Directory Id="photo" Name="photo" />
            <Directory Id="person" Name="person" />
            <Directory Id="iSpyServer" Name="iSpyServer" />
            <Directory Id="Backgrounds" Name="Backgrounds" />
            <Directory Id="Masks" Name="Masks" />
            <Directory Id="Commands" Name="Commands" />
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>
  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="{181C0827-C961-4A54-B4F5-BB1A51524619}">
        <Shortcut Id="ApplicationStartMenuShortcut" Name="海鹰系统" Description="iEagle Video Surveillance Software" Target="[INSTALLFOLDER]iEagle.exe" WorkingDirectory="INSTALLFOLDER" />
        <!--<Shortcut Id="SilentStart" Name="iSpy Silent Start" Description="iEagle Video Surveillance Software" Target="[INSTALLFOLDER]iEagle.exe" WorkingDirectory="INSTALLFOLDER" Arguments="-silent" />
        <Shortcut Id="ResetProduct" Name="系统重置" Description="iEagle Video Surveillance Software" Target="[INSTALLFOLDER]iEagle.exe" WorkingDirectory="INSTALLFOLDER" Arguments="-reset" />
        -->
        <Shortcut Id="UninstallProduct" Name="卸载" Description="Uninstalls iEagle" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]"/>
        <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\iEagle" Name="installed" Type="integer" Value="1" KeyPath="yes" />
        <RegistryValue Root="HKCU" Key="Software\iEagle" Name="firstrun" Type="integer" Value="1" KeyPath="no" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="{360F5BA0-D29A-4D16-AD53-3946A9E29E19}">
        <Shortcut Id="ApplicationDesktopShortcut" Name="海鹰系统" Description="iEagle Video Surveillance Software" Target="[INSTALLFOLDER]iEagle.exe" WorkingDirectory="INSTALLFOLDER" />
        <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\iEagle" Name="desktopsc" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="TARGETDIR">
      <!--Merge file path doesn't process variables for some reason so has to be an explicit path -->
      <Merge Id="VCRedist" SourceFile="D:\iSpy-master\C++\Microsoft_VC140_CRT_x86.msm" DiskId="1" La

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值