我正在尝试实现自动版本控制,以便在构建Bootstrapper时,MyApp和Bootstrapper版本都会自动递增和同步。否则,对于每个具有匹配版本的安装尝试,您最终会在添加/删除程序中使用重复的引导条目。
当我构建引导程序时,AfterBuild目标使用GetAssemblyIdentity
成功获取自动生成的MyApp版本,并且使用递增的版本号正确命名引导程序输出文件,例如MyApp.1.0.5123.1352.exe
但是,当我安装此Bootstrapper时,添加/删除程序中显示的版本始终为1.0.0.0
。
我尝试在Bootstrapper Bundle Version字段中使用绑定,但我无法阅读MyApp版本。
使用!(bind.packageVersion.MyApp)
会导致从不递增1.0.0.0
使用!(bind.assemblyName.MyApp)
会导致构建错误(未解析的绑定时变量)
使用!(bind.FileVersion.filAAF013CA9B89B07C81031AE69884BF11)
会导致构建错误(未解析的绑定时变量)。 < - 有意义,因为Setup
项目中存在FileID,这是Bootstrapper
项目。
如何让我的Bootstrapper Bundle拥有相同的版本呢? 作为MyApp的包装?
===== MyApp的\的AssemblyInfo.cs =====
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
===== Setup.wixproj =====
<Target Name="BeforeBuild">
<PropertyGroup>
<LinkerBaseInputPaths>..\MyApp\bin\$(Configuration)\</LinkerBaseInputPaths>
</PropertyGroup>
<HeatDirectory OutputFile="MyApp_Files.wxs" Directory="..\MyApp\bin\$(Configuration)\" DirectoryRefId="INSTALLLOCATION" ComponentGroupName="MyApp_Project" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" Condition="'%(ProjectReference.PackageThisProject)'=='True'" />
</Target>
===== Bootstrapper.wixproj =====
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="..\MyApp\bin\$(Configuration)\MyApp.exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<Copy SourceFiles=".\bin\$(Configuration)\$(OutputName).exe" DestinationFiles=".\bin\$(Configuration)\MyApp.%(AssemblyVersion.Version).exe" />
<Delete Files=".\bin\$(Configuration)\$(OutputName).exe" />
</Target>
=====引导程序\ Bundle.wxs =====
<Bundle Name="$(var.ProductName) Bootstrapper v!(bind.packageVersion.MyApp)"
Version="!(bind.packageVersion.MyApp)"
答案 0 :(得分:20)
这就是我要做的事情:
在我的程序集中,我使用自动版本控制:AssemblyVersion("1.0.*")
在安装项目中引用使用绑定到程序集的版本:!(bind.fileVersion.MyAssembly.dll)
(MyAssembly.dll是程序集的File / @ Id)
!(bind.packageVersion.Setup)
(安装程序是捆绑项目中引用的项目名称。)答案 1 :(得分:6)
得到了!!!我没有意识到您可以在DefineConstants
目标中声明变量aka BeforeBuild
。
以下是生成变量BuildVersion
Bundle.wxs:
<Bundle Name="$(var.ProductName) Bootstrapper v$(var.BuildVersion)"
Version="$(var.BuildVersion)"
Bootstrapper.wixproj:
<Target Name="BeforeBuild">
<GetAssemblyIdentity AssemblyFiles="..\MyApp\bin\$(Configuration)\MyApp.exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<PropertyGroup>
<DefineConstants>BuildVersion=%(AssemblyVersion.Version)</DefineConstants>
</PropertyGroup>
</Target>
<!-- This is extra, not needed: Renames output file with version number -->
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="..\MyApp\bin\$(Configuration)\MyApp.exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<Copy SourceFiles=".\bin\$(Configuration)\$(OutputName).exe" DestinationFiles=".\bin\$(Configuration)\MyApp.%(AssemblyVersion.Version).exe" />
<Delete Files=".\bin\$(Configuration)\$(OutputName).exe" />
</Target>