首页 > 解决方案 > (我可以/我如何)从 WiX 访问程序集信息

问题描述

我正在学习如何使用 WiX 为我的项目创建安装程序,并希望能够引用我的 VS2019 C# 项目的程序集信息,这些信息是从我的 .wxs 文件中的项目属性 > 应用程序 > 程序集信息按钮填充的。

我知道我可以使用添加项目作为参考,然后使用$(var.MyProject.???)声明,但我不知道在哪里可以找到项目的可行点符号属性列表。或者,我知道我可以使用 '' with<Package Manufacturer="$(var.CompanyName)" .../>来省去多次输入数据的麻烦,但我仍然更愿意将它从项目中拉出来并放在一个地方。

清晰的图像

谢谢

SEO 术语:wix 汇编版本。蜡组装信息

标签: c#visual-studiowixpreprocessor

解决方案


Light.exe:在此处查看 WiX light.exe 文档: https ://wixtoolset.org/documentation/manual/v3/overview/light.html#standard-binder-variables

如果您想将主程序集的版本作为设置的 ProductVersion 运行,您应该能够执行以下操作:

<Product Id="*" Name="MyProject" Version="!(bind.fileVersion.MyMain.exe)"
         Manufacturer="MyCorp" Language="1033" UpgradeCode="PUT-GUID-HERE">

 <..>

  <Component Feature="Main">
    <File Id="MyMain.exe" Source="MyMain.exe"></File>
  </Component>

WiX 示例在此处完成 Github.com 示例

和可用于所有版本化的二进制文件fileLanguagefileVersionDot NET 程序集支持许多其他变量 -请参阅文档(与答案顶部的链接相同)。

Rob Mensching WiX 的创建者 Mensching 在这里给出了答案精华"You can drive your product version off of an assembly's version using "!(bind.assemblyVersion.FileId)". ... You can only specify binder variables in .wxs files. It's a binder (in light.exe) concept not an MSBuild (in MSBuild.exe reading .wixproj files) concept"

Heath Stewart:请查看此博客以获取有关 .NET 程序集值的一些信息: https ://devblogs.microsoft.com/setup/get-binder-variables-for-assemblies-without-installing-into-the-gac/ - Essence"...to get binder variables for assemblies without installing into the GAC set File/@Assembly to “.net” or “win32”, then for the same file set File/@AssemblyApplication to the value for File/@Id"


链接:


推荐阅读