Jan*_*Jan 26 variables installation windows-installer wix
我想在wix项目生成的msi文件的文件名中包含一些动态部分.这个动态部分应该由变量控制,这些变量是我的wix项目的一部分,并且声明如下:
<?define ProductVersion="7.1.0.1" ?>
Run Code Online (Sandbox Code Playgroud)
有没有人知道将wix变量的值发送给链接器以将其用作输出文件名的一部分的方法?
顺便说一下:我正在使用Wix3
小智 47
您可以更新.wixproj的OutputName并使用MSBuild变量来传递版本号或您喜欢的任何其他变量.
我的构建脚本如下所示:
set PRODUCTVERSION=7.1.0.1
MSBuild.exe /p:Configuration=Debug /p:ProductVersion=%PRODUCTVERSION% Installer.wixproj
Run Code Online (Sandbox Code Playgroud)
我的WiX项目看起来像这样:
<?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>
Run Code Online (Sandbox Code Playgroud)
输出将是:
Installer.7.1.0.1.msi
Run Code Online (Sandbox Code Playgroud)
Wim*_*nen 16
msi文件名不是由您的wix文件决定的,而是由light.exe -out交换机确定的.-out如果在构建脚本中执行以下操作,则可以在wix文件中使用相同的值,假设它是批处理脚本:
set
productversion=1.2.3-out foo%productversion%.msi给
light.exe链接器$(env.productversion)我发现了一些很好的参考文章来完成此操作:
http://blog.tentaclesoftware.com/archive/2009/05/03/38.aspx
以及后续的使用预构建事件创建输出文件的更好方法:
http://blog.tentaclesoftware.com/archive/2010/08/05/99.aspx
我知道链接很旧,但是方法是正确的。
以下是基本步骤:
将您要使用的版本放入可以从项目中访问的文件中。我使用安装的主要可执行文件,因为我也在wxs中绑定到该版本。就我而言,由于我使用C#进行构建并使用SVN,因此我具有我的assembly.cs,assembly.cs.txt的模板版本,可将subwcrev作为预构建事件运行以创建Assembly.cs,编译成可执行文件(实际上是在解决方案的一个单独项目中完成)。Subwcrev插入一些日期和修订信息,这些信息用于创建版本为“ major.minor.version.0”的版本,其中我使用“ year.month.revision.0”作为版本。
现在,我通常只使用这种方法设置AssemblyFileVersion,但是为了能够在上面的帖子中引用的wixproj构建事件中使用我的版本号,我还需要设置AssemblyVersion,因为可以通过GetAssemblyIdentity进行访问。如果我确实在使用别人链接的程序集,则此方法会令人怀疑,但是对我来说这是可以的,因为它在我的最终应用程序可执行文件中。
请遵循第二篇文章中概述的步骤(第一篇文章讨论了在wxs中使用版本的绑定方法以及如何卸载和编辑wixproj-第二篇文章的宝贵上下文)。
奇迹般有效!
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>
Run Code Online (Sandbox Code Playgroud)
Output = App_1.0.0.0_Debug.msi
既然它只是一个文件名,为什么不进行构建后操作来重命名构建脚本中的文件(假设是 MSBuild)?