我在VS2019中使用Wix v3.11为我们的应用程序创建一个设置。为了方便维护,我需要将安装程序文件复制到一个文件夹中,其中包含路径中的版本。
基本上,我的想法是使用post build事件将文件复制到\$(BootstrapPackageVersion)\$(Configuration)\目录,但我无法找到这样的变量。
我尝试从.exe包中提取版本(因为它是从MSI包中提取的,而MSI包本身也是从原始应用程序获得它的版本,就像预期的那样),.wixproj文件中的代码如下:
</PropertyGroup>
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersions" />
</GetAssemblyIdentity>
<CreateProperty Value="$(TargetDir)/%(AssemblyVersions.Version)/">
<Output TaskParameter="Value" PropertyName="CustomTargetName" />
</CreateProperty>
<Copy SourceFiles="$(TargetDir)/*" DestinationFolder="$(CustomTargetName)"/>
</Target>但是,如果出现以下错误,则会失败:
无法为"Path\Setup.exe“获取程序集名称。无法加载文件或程序集“Setup.exe”或其依赖项之一。预计该模块将包含程序集清单。
我看到有一个属性,$(WixBundleVersion),但它似乎不能用于构建事件。
基本上,我想要实现的是一件相当简单的事情:将引导程序项目的输出复制到包含包版本的另一条路径中。有可能吗?
发布于 2022-02-11 11:37:32
我在wix项目中这样做的方法是将setup.exe输出到它的默认文件夹中,然后运行一个AfterBuild并将其复制到最终的工件目录中
在wixproj中:
<Target>
...
<GetAssemblyIdentity AssemblyFiles="..\MyApp.App\bin\$(Configuration)\net5.0\FrameworkDep\win-$(Platform)\Publish\MyApp.App.dll">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<PropertyGroup>
<DefineConstants>BuildVersion=%(AssemblyVersion.Version)</DefineConstants>
</PropertyGroup>
...
</Target>
<Target Name="AfterBuild">
<Copy SourceFiles=".\bin\$(Configuration)\en-us\$(OutputName).msi" DestinationFiles=".\bin\$(Configuration)\$(OutputName)_%(AssemblyVersion.Version).msi" />
</Target>这将分配BuildVersion,然后您可以在wxs文件中使用它,并在wixproj和%(AssemblyVersion.Version)中使用AssemblyVersion。
AfterBuild部分正在将msi复制到MyApp_1.2.3.msi。
在我的wxs文件中我可以使用:
<Product Id="*" Name="My App" Language="1033"
Version="$(var.BuildVersion)>然后使用上面的构建版本,所以我只是版本控制MyApp.App项目。
https://stackoverflow.com/questions/71078890
复制相似问题