Passing build parameters to .wxs file to dynamically build wix installers

后端 未结 3 2148
臣服心动
臣服心动 2021-02-13 21:52

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

3条回答
  •  猫巷女王i
    2021-02-13 22:21

    The reason it's not working for you is that you are setting msbuild properties on the command line, which are not getting passed through as wix variables. MSBuild properties and wix variables are two different concepts.

    One way to fix this is to ignore the concept of msbuild properties and use environment variables to pass values directly to candle.exe. You can use environment variables in your wxs file like this:

    $(env.SpecialPath)
    

    You can then launch your setup build from a batch file which prepares the necessary environment variables like this:

    @echo off
    setlocal
    
    set SpecialPath=foo
    set Configuration=Release
    set msbuild=C:\windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
    
    %msbuild% test.wixproj /t:Build || goto ERROR
    
    exit /b 0
    
    :ERROR
    echo Failed to build setup!
    exit /b 1
    

    Alternatively, if you prefer to pass parameters via msbuild properties, you should first take a look at the msbuild candle task documentation. It shows you can set values in your wixproj file like this:

    Variable1=value1;Variable2=value2
    

    This still requires you to hardcode values in the wixproj file though. If you want to pass the values as msbuild properties on the command line, then you should probably do something like this:

    Variable1=$(value1);Variable2=$(value2)
    

    and then pass /p:value1=foo /p:value2=bar on the command line, or define these msbuild properties elsewhere.

提交回复
热议问题