WIX: Howto set the name of the msi output file dynamically

后端 未结 8 516
时光取名叫无心
时光取名叫无心 2021-01-31 16:44

I want to include some dynamic part in the filename of the msi file my wix projects produce. This dynamic part should be controlled by variables which are part of my wix project

相关标签:
8条回答
  • 2021-01-31 17:28

    If you have several configuration than within .wixprj file you can do the following

    <OutputName Condition="'$(Configuration)' == 'User'">User.Setup</OutputName>
    <OutputName Condition="'$(Configuration)' == 'Designer'">Designerr.Setup</OutputName>
    
    0 讨论(0)
  • 2021-01-31 17:30

    Open *.wixproj (example: Setup.wixproj)

    Go to the end of the file.

    $(Configuration) = Debug| Release …

    Set path of your application on AssemblyFiles.

    <Target Name="BeforeBuild">
        <GetAssemblyIdentity AssemblyFiles="..\App\bin\$(Configuration)\App.exe">
          <Output TaskParameter="Assemblies" ItemName="AsmInfo" />
        </GetAssemblyIdentity>
        <CreateProperty Value="$(SolutionName)_%(AsmInfo.Version)_$(Configuration)">
          <Output TaskParameter="Value" PropertyName="TargetName" />
        </CreateProperty>
    </Target>
    

    Output = App_1.0.0.0_Debug.msi

    0 讨论(0)
  • 2021-01-31 17:30
    Product Id="GUID" Name="whatevername $(var.ProductVersion)" 
    
    0 讨论(0)
  • 2021-01-31 17:39

    You could update the OutputName of your .wixproj and use an MSBuild variable to pass through the version number or any other variable you like.

    My build script looks like this:

    set PRODUCTVERSION=7.1.0.1
    MSBuild.exe /p:Configuration=Debug /p:ProductVersion=%PRODUCTVERSION% Installer.wixproj
    

    And my WiX project looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
        <ProductVersion>1.0.0.0</ProductVersion>
        <ProjectGuid>{b7415c44-8d59-4ac2-b698-03e399a305e3}</ProjectGuid>
        <SchemaVersion>2.0</SchemaVersion>
        <OutputName>Installer.$(ProductVersion)</OutputName>
        ...
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
        <OutputPath>bin\$(Configuration)\</OutputPath>
        <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
        <DefineConstants>Debug</DefineConstants>
        <WixVariables>ProductVersion=$(ProductVersion)</WixVariables>
      </PropertyGroup>
      ...
    </Project>
    

    The output would be:

    Installer.7.1.0.1.msi
    
    0 讨论(0)
  • 2021-01-31 17:43

    Do the variables have to be defined in WiX? I'm building my setup binaries from MSBuild, and I've simply set the output file name to MyProject_$(Platform) -- I expect that any MSBuild variable substitution will work equally well.

    0 讨论(0)
  • 2021-01-31 17:44

    The msi file name is not determined by your wix files, but by the light.exe -out switch. You can use the same value for -out and inside your wix files if you do the following in your build script, assuming it is a batch script:

    • set an environment variable with set productversion=1.2.3
    • Pass -out foo%productversion%.msi to the light.exe linker
    • use the same environment variable in your wix files as $(env.productversion)
    0 讨论(0)
提交回复
热议问题