- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前,每当我构建我的包时,我都必须手动增加 Product.wxs 文件中的 Version 属性,如下所示:
<Product
Id = "*"
Version="4.1.3"
我想将其自动化,以简化构建过程。我们对 exe/dll 文件使用以下版本控制方案:
major.minor.special.build
特殊的几乎从不使用,设置为 0,约定是将打包的 MSI 版本化如下,因为您只能使用三个数字:
major.minor.build
我见过的唯一解决方案是让您获取另一个项目的 4 位数版本,然后截断构建版本,所以您最终会得到这样的结果:
major.minor.special
显然这不适用于我们的方案,因为我们丢失了内部版本号。我如何获取 major.minor.build
,忽略特殊?
最佳答案
我使用一个包含文件中的 WiX 变量,我在每次构建时都会重新生成该文件。
由于我的项目是 .wixproj (MSBuild/Visual Studio),我只是在其中将版本提取和格式设置编码为自定义的内联 MSBuild 任务,并在 BeforeBuild 目标中调用它。
在下面的示例中,我获取了产品主程序集的程序集版本。您可以为任何您想要的版本编写代码。
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include ProductVersion.wxi?>
<Product Version="$(var.ProductVersion)" …>
…
</Wix>
<Include>
<?define ProductVersion=1.0.38549?>
</Include>
我建议在项目中包含 .wxi 文件,以便它在解决方案 View 中可见。而且,由于它已生成,我建议将其从源代码管理中排除。
.wixproj 既是 Visual Studio 项目文件又是 MSBuild 项目文件。要在 Visual Studio 中编辑 Visual Studio 项目文件,请选择 tutorial or extension .
MSBuild 系统(包括 WiX 的)提供 BeforeBuild 和 AfterBuild 目标,如 .wixproj 注释中所述。
只需从评论中拉出目标并添加任务调用即可。
<Target Name="BeforeBuild">
<GenerateProductVersion AssemblyPath='../wherever/whatever.exe' />
</Target>
任务代码可以放在它自己的 MSBuild 文件中,甚至可以放在 DLL 中以供重用。或者,对于脚本方法,它可以是内联的。
此任务分为 3 个部分:
.
<UsingTask TaskName="GenerateProductVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<AssemblyPath ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Using Namespace="System" />
<Using Namespace="System.Xml.Linq" />
<Using Namespace="System.Reflection" />
<Code Type="Fragment" Language="cs"><![CDATA[
var assemblyVersion = AssemblyName.GetAssemblyName(AssemblyPath).Version;
var productVersion = String.Format("{0}.{1}.{2}", assemblyVersion.Major, assemblyVersion.Minor, assemblyVersion.Revision);
Log.LogMessage(MessageImportance.High, "ProductVersion=" + productVersion + " extracted from assembly version of " + AssemblyPath);
new XDocument(
new XElement("Include",
new XProcessingInstruction("define", "ProductVersion=" + productVersion)))
.Save("ProductVersion.wxi");
]]></Code>
</Task>
</UsingTask>
所有这些都隐藏在项目文件中。许多项目设计者都有一个构建选项卡,允许在构建中输入名称-值对。这提供了一种从 XML 中向上提升路径的机制。
<Target Name="BeforeBuild">
<GenerateProductVersion AssemblyPath='$([System.Text.RegularExpressions.Regex]::Match(";$(DefineConstants);", ";VersionExtractionPath=(?<path>.*?);").Groups["path"].Value)' />
</Target>
关于wix - 配置 WiX 以自动设置产品版本属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46835233/
我一直在尝试查找文章或发布列出 WiX (Windows Installer XML)/WiX 工具集的功能限制的文章,但均未成功。使用 WiX 几个星期后,我至少能想到两个 限制 在最新的 RTM
我们在 SomeDialog.wxs 文件中有一个 WiX 片段,它会提示用户输入一些信息。它在 InstallerUI.wxs 文件中控制对话框顺序的另一个片段中被引用。当然,Product.wxs
我们有多个配置文件。根据所选的环境,正确的文件将被复制,其余文件应被删除。 我正在使用RemoveFile,但是不会删除任何内容,或者可能是我没有正确使用它。复制所有文件后,有人可以举一个例子在安装过
我正在为现有产品编写 MSI。在以前的版本中有一个自定义操作,它不仅限于在安装时运行,现在在使用 MajorUpgrade 卸载时失败。 新安装程序中是否有任何方法可以告诉 WiX 在卸载时跳过该特定
我需要在安装之前检查 .NET Framework。我添加了这个 文件的开头包含 并在链接时出现错误 error LGHT0094 :
如果在功能选择树中选择了另一个功能,是否有任何方法可以强制安装特定功能?那就是没有让功能成为它们依赖项的子项? 最佳答案 是的,这应该是可能的,如果您在 Feature 元素下使用 Condition
有没有办法在 WiX 中强制自动登录? 目前,要生成日志,我需要使用此参数执行我的包: application.msi /l*v log.txt 我想在 中找到一个方法标记 - 例如 - 强制日志始
我正在为我的项目创建一个 WIX 模板,以确保相对标准的布局。 我已经使用 定义了一个变量来引用主应用程序其中 MyApp 是引用项目的名称。然后,我使用 MainApp 变量在 .wxs 和 .w
我有一个名为 MyProject(P2P) 的 visual studio 项目,它一直运行良好。 现在我正在使用 Wix 3 将这个项目打包到 MSI 中,其中一个步骤是编写组件节点:
我正在使用Wix 3.6。我有一个问题,在卸载时是否打开了任何窗口并显示在任务栏中(此窗口是我试图卸载的msi的一部分),它显示了一个对话框,要求用户关闭应用程序(“在继续安装之前,应关闭以下应用程序
我需要澄清 *.wxs 文件中的目录结构。据我所知,它将文件安装在我们在目录元素中指定的目录中。它还有其他用途吗? 如果它确实描述了将安装产品的目录结构,那么如果用户在安装程序中有浏览选项会发生什么。
我们已经为我们的应用程序创建了 WIX 安装程序。我们面临的问题是: 我们已经定义了两个不同的自定义操作(比如 ActionForInstall 和 ActionForUninstall),我们希望在
我有一个应用程序安装程序,无论版本号如何,都需要通过任何现有版本进行安装。 相反,我有一个安装程序,不断说我需要添加/删除程序。对于我的测试人员而言,这是非常令人沮丧的行为,因为这只会在没有真正原因的
我正在使用VS 2010创建一个由Wix安装的程序,并且已经准备好product.wxs。 在我的wxs文件中,我有类似以下的目录定义:
关注 example here ,我在 ProgramMenuFolder 中添加了一个快捷方式启动我的应用程序。 (我的代码实际上更简单,因为我不需要额外的文件夹。)
即使在重新启动后,服务仍然存在,即使可执行文件消失了。我正在使用 WIX 版本 3.0.5419.0 安装 Windows 服务工作正常。卸载它似乎什么也没做。卸载日志文件的部分
我正在尝试配置 WiX 设置和库,以便将库中文件之一的版本用作设置中的 Product/@Version。 背景 在本地定义文件的设置中,这相对简单,因为假设组件项目被 WiX 项目引用然后配置:
我想在wix项目生成的msi文件的文件名中包含一些动态部分。这个动态部分应该由变量控制,这些变量是我的wix项目的一部分,并且应这样声明: 有谁知道将wix变量的值发送给链接器以将其用作输出文件名的
我真的觉得我不必为了获得这样的基本信息而在SO上提问,但是我在任何地方都找不到可靠的消息来源。 WiX v4是否已发布?开发中?在Beta中?还在设计中? 如此看来,许多人似乎已经在使用WiX v4。
如果注册表项 HKEY_CURRENT_USER\Control Panel\International\LocaleName 的值为 de-DE,我希望将 INSTALL_DE 属性值设置为 1。
我是一名优秀的程序员,十分优秀!