无论如何要在WIX wxs文件中创建自定义MSBuild属性? [英] Anyway to create a custom MSBuild property in WIX wxs file?

查看:108
本文介绍了无论如何要在WIX wxs文件中创建自定义MSBuild属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用WIX 3.6项目中的版本号自动命名输出的msi文件.我找到此链接: 已重新访问了WiX的自动安装程序版本号,但我们略有改动不同的情况:我们不想通过引用任何程序集的版本号来控制我们的产品版本号.相反,我们只是想在wix文件中分配它.具体来说,我有一个wxi文件,它定义了这样的属性:

My target is to auto-name the output msi file with version number in WIX 3.6 project. I find this link: Automated installer version numbers for WiX, revisited but we have a slightly different scenario: we don't want to control our product version number by referencing to any assembly's version number. Instead, we just simply want to assign it in wix files. Specifically, I have a wxi file which defines a property like this:

<?define VersionNumber = "1.1.2000" ?>  

因此,我可以在Product.wxs文件中的任何位置使用此VersionNumber变量.但是,由于重命名输出msi文件的最简单方法似乎是在MSBuild中添加一个postbuild任务,因此我必须将此VersionNumber传递给MSBuild项目文件.这就是阻止我的原因.

As a result, I can use this VersionNumber variable anywhere inside our Product.wxs file. But since the easiest way to rename the output msi file seems to be adding a postbuild task in MSBuild, I must pass this VersionNumber out to the MSBuild project file. This is what stops me.

我尝试了另一种方法,即在MSBuild中定义VersionNumber常量,并在WIX中使用它.它工作正常,但对于不同的Build/Platform组合,我必须保持此常数不变.我们正在VS IDE中构建软件,这意味着如果我们在IDE窗口中修改版本号,它将仅适用于特定的Build/Platform组合,而其他组合将保持不变(我知道如果我是从命令行构建的,我可以只需传递一个版本号即可覆盖现有版本号).那就是我不想看到的.我喜欢只在一个地方定义版本号以避免任何可能的错误的想法.

I tried the other way around, i.e., to define the VersionNumber constant in the MSBuild and use it inside WIX. It works fine except I must keep this constant the same for different Build/Platform combinations. We are building our software in VS IDE which means if we modify the version number in IDE's window, it would only apply to the specific Build/Platform combination and the other combinations will remain unchanged(I know if I am building from command line I can simply pass a version number to overwrite the existing one). And that is what I don't want to see. I like the idea to only define the version number in one place to avoid any possible mistake.

任何帮助将不胜感激!

推荐答案

在设置项目属性的构建"选项卡中选择所有配置"和所有平台"后,定义预处理程序变量.

Define the preprocessor variable after choosing "All Configurations" and "All Platforms" in the Build tab of the setup project properties.

您可以通过将.wixproj中的元素添加到仅保留版本号的项目中来实现.您只需修改一次.wixproj即可.您可能可以通过合理的操作将此属性文件添加到.wixproj本身(无?),以便您可以在IDE中对其进行修改.

You can achieve this by adding an element in your .wixproj to a project where you just keep the version number. You'd modify the .wixproj, but only once. And you can probably add this properties file to the .wixproj itself with a reasonable action (None?) so you can modify it from within the IDE.

类似的东西:

Version.properties

Version.properties

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <WhateverTheVersionPropertyNameIs>x.x.x.x</WhateverTheVersionPropertyNameIs>
  </PropertyGroup>
</Project>

在.wixproj文件中,您将在末尾添加

In your .wixproj file you'd add at the end

<Import Project="Version.properties"/>

这篇关于无论如何要在WIX wxs文件中创建自定义MSBuild属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆