将构建参数传递到.wxs文件以动态构建wix安装程序 [英] Passing build parameters to .wxs file to dynamically build wix installers

查看:115
本文介绍了将构建参数传递到.wxs文件以动态构建wix安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名学生开发人员,并且为我现在与之合作的公司构建了多个安装程序.因此,我对WIX相当熟悉. 我们最近决定拥有一个可自动构建我们的解决方案的构建服务器.它构建调试和发布版本,以及混淆(和非混淆)项目. 而且您真的不需要了解任何这些.您需要了解的是,我有一个相同的Wix项目,可以动态地构建不同的MSI. 因此,构建它们的方式是使用几个参数调用MSBuild.exe. wix项目所依赖的参数.

I am a student developer and I have built several installers for the company I am working with now. So I am fairly familiar with WIX. We recently decided to have a Build server that auto builds our solution. It builds both debug, and release, as well as Obfuscated (and non obfuscated) projects. And you really don't have to understand any of this. All you have to understand is that I have the same Wix project building different MSIs dynamically. So the way we build them is we call MSBuild.exe with several parameters. Parameters the wix project depends on.

所以,假设我们进入命令提示符并编写

So let's say we go into command prompt and write

C:\>\windows\Microsoft.NET\Framework\v3.5\MSBuild.exe MyApp.Install\MyApp.Install.wixproj /p:Configuration=Release /p:SpecialPath=Obfuscated /t:Build

这个想法是,wix看到"SpecialPath"参数被分配为"Obfuscated";并在安装程序路径中将其源 ..\myApp\bin\$(var.SpecialPath)\myApp.exe,在构建时会转换为..\myApp\bin\Obfuscated\myApp.exe.

The idea is that wix sees the "SpecialPath" parameter being assigned "Obfuscated"; and in the installer paths its source to ..\myApp\bin\$(var.SpecialPath)\myApp.exe which translates to ..\myApp\bin\Obfuscated\myApp.exe when built.

如何创建这些自定义构建参数,并将其传递到我的.wxs文件.到目前为止,使用 this 设置时,尚未定义$(var.SpecialPath)并构建了CrashSplosions.

How do you create those custom build parameters and have them passed to my .wxs file. As of now with this setup, $(var.SpecialPath) is not defined and the build CrashSplosions.

出于明显的法律原因,我不得不删除了project.wxs文件的90%并重命名了一些内容,但是出于所有意图和目的,这就是我的意思.

For obvious legal reasons I had to cut 90% of the project.wxs file out and rename some stuff, but for all intents and purposes this is what I have.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="myApp" Language="1033" Version="$(var.Version)" Manufacturer="myApp" UpgradeCode="$(var.UpgradeCode)">
<Package Id="*" InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media.cab" EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir" >
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLLOCATION" Name="myApp"> 

      <Component Id="myAppEXE" Guid="FD5EBC02-MY29-GUID-ACCA-61324C5F1B68">
        <RegistryKey Root="HKLM" Key="Software\MyApp">
          <RegistryValue Value="0" Type="string" KeyPath="yes"/>
        </RegistryKey>
        <File Id="MYAPPEXE" Name='myApp.exe' Source="..\myApp\bin\$(var.SpecialPath)\myApp.exe" />
      </Component>

      <Component Id="EngineDLL" Guid="*">
        <File Id="ENGINEDLL" Name='Engine.dll' Source="..\myApp\bin\$(var.Configuration)\Engine.dll" />
      </Component>
      <Component Id="CommonDLL" Guid="*">
        <File Id="COMMONDLL" Name='Common.dll' Source="..\myApp\bin\$(var.Configuration)\Common.dll" />
      </Component>

    </Directory>
  </Directory>
</Directory>

<Feature Id="ProductFeature" Title="myApp" Description='All' Display='expand' Level="1" ConfigurableDirectory='INSTALLLOCATION'>
  <ComponentRef Id="myAppEXE" />
  <ComponentRef Id="EngineDLL" />
  <ComponentRef Id="CommonDLL" />
</Feature>
</Product>
</Wix>

推荐答案

正如已经回答的那样,您需要将变量传递到WiX中.我们使用Nant代替MSBuild,但是概念保持不变.

As already answered, you need to pass the variables into WiX. We use Nant instead of MSBuild, but the concept remains the same.

这是一个Nant示例,将六个变量传递给了蜡烛(这不是最干净的示例,但是是从我所从事的项目中逐字逐句地提取出来的)

Here's a Nant example passing in half a dozen variables to candle (it's not the cleanest example, but is lifted verbatim from a project I worked on)

<candle   out="${dir.obj}\"
          rebuild="true"
          extensions="WixUIExtension;WixNetFxExtension">
    <defines>
        <define name="ProcessorArchitecture" value="${release.platform}" />
        <define name="SourceDir" value="${dir.source}" />
        <define name="version" value="${version}" />
        <define name="releasetype" value="${release.type}" />
        <define name="Language" value="${language}" />
        <define name="product" value="${string.product}" />
        <define name="productedition" value="${release.productedition}" />
    </defines>

    <sources>
        <include name="*.wxs" />
        <include name="..\Common\*.wxs" />
    </sources>
</candle>

<!-- Define fallback culture for non-US -->
<property name="cultures" value="${language}" />
<property name="cultures" value="${language};en-US" unless="${language == 'en-US'}" />

<light
  out="${dir.build}\setup_${release.platform}_${release.compressionlevel}.msi"
  extensions="WixUIExtension;WixNetFxExtension;WixUtilExtension"
  cultures="${cultures}"
  rebuild="true"
  suppressices="ICE03;ICE82"
  suppresspdb="true" >


    <arg line="-loc &quot;setup-${language}.wxl&quot;" />
    <arg line="-sw1101" />

    <arg line="-b ${dir.resources}" />
    <arg line="-b ${dir.resources.common}" />
    <arg line="-b ${dir.resources.common}\Microsoft" />
    <arg line="-b ${dir.source}" />
    <arg line="-dcl:${release.compressionlevel}" />
    <arg line="-dWixUILicenseRtf=EULA_${language}.rtf" />
    <sources>
        <include name="${dir.obj}\*.wixobj" />
    </sources>
</light>

这篇关于将构建参数传递到.wxs文件以动态构建wix安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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