构建 MSI 文件(wix 项目)时,在文件名(OutputName)中包含 MajorVersion 等 [英] Include MajorVersion etc in filename (OutputName) when building MSI file (wix project)

查看:15
本文介绍了构建 MSI 文件(wix 项目)时,在文件名(OutputName)中包含 MajorVersion 等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Defines.wxi 中有:

In my Defines.wxi I have:

<?define MajorVersion="1" ?>
<?define MinorVersion="08" ?>
<?define BuildVersion="11" ?>

在我的 MyProject.Setup.wixproj 我有:

In my MyProject.Setup.wixproj I have:

<OutputName>MyProject</OutputName>
<OutputType>Package</OutputType>

是否可以以某种方式在文件名中包含版本变量,以便我的文件可以命名为 MyProject.1.08.11.msi?

Is it possible to include the version variables in the filename somehow, so that my file can be named MyProject.1.08.11.msi?

这不起作用(没有定义这样的变量):

This didn't work (no such variable is defined):

<OutputName>MyProject-$(MajorVersion)</OutputName>
<OutputType>Package</OutputType>

这不起作用(没有定义这样的变量):

This didn't work (no such variable is defined):

<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
    <Copy SourceFiles="$(OutputPath)$(OutputName).msi" DestinationFiles="C:$(OutputName)-$(MajorVersion).msi" />
</Target>

我似乎很清楚 $(MajorVersion) 不是从 Defines.wxi 文件中获取定义的正确方法.是什么?

It seems very clear to me that $(MajorVersion) is not the correct way of fetching the definition from the Defines.wxi file. What is?

更新

我试图把它放在 MyProject.Setup.wixproj 中:

I tried to put this in MyProject.Setup.wixproj:

<InstallerMajorVersion>7</InstallerMajorVersion>
<InstallerMinorVersion>7</InstallerMinorVersion>
<InstallerBuildNumber>7</InstallerBuildNumber>

...

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <OutputPath>bin$(Configuration)</OutputPath>
    <IntermediateOutputPath>obj$(Configuration)</IntermediateOutputPath>
    <DefineConstants>PrebuildPath=....objprebuildweb;InstallerMajorVersion=$(InstallerMajorVersion);InstallerMinorVersion=$(InstallerMinorVersion);InstallerBuildNumber=$(InstallerBuildNumber)</DefineConstants>
</PropertyGroup>

这在Defines.wxi中:

And this in Defines.wxi:

<?define MajorVersion="$(var.InstallerMajorVersion)" ?>
<?define MinorVersion="$(var.InstallerMinorVersion)" ?>
<?define BuildVersion="$(var.InstallerBuildNumber)" ?>
<?define Revision="0" ?>
<?define VersionNumber="$(var.InstallerMajorVersion).$(var.InstallerMinorVersion).$(var.InstallerBuildNumber)" ?>

也没有用.收到以下错误消息:

Didn't work either. Got these error messages:

  • Product/@Version 属性的值.."不是有效版本.合法版本值应类似于x.x.x.x",其中 x 是整数从 0 到 65534.
  • 未找到 Product/@Version 属性;它是必填.

推荐答案

这就是我最终的结果,并且有效!

This is what I ended up with, and it works!

Setup.Version.proj

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <InstallerMajorVersion>55</InstallerMajorVersion>
        <InstallerMinorVersion>66</InstallerMinorVersion>
    <InstallerBuildVersion>$(BuildNumber)</InstallerBuildVersion>
        <InstallerBuildVersion Condition="$(InstallerBuildVersion) == ''">0</InstallerBuildVersion>
  </PropertyGroup>
</Project>

MyProject.Setup.wixproj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="Setup.Version.proj" />
  <PropertyGroup>
    <OutputName>MyProject_$(InstallerMajorVersion)_$(InstallerMinorVersion)_$(InstallerBuildVersion)</OutputName>
    <OutputType>Package</OutputType>
    <DefineConstants>InstallerMajorVersion=$(InstallerMajorVersion);InstallerMinorVersion=$(InstallerMinorVersion);InstallerBuildVersion=$(InstallerBuildVersion)</DefineConstants>
    ...

Defines.wxi

<?define MajorVersion="$(var.InstallerMajorVersion)" ?>
<?define MinorVersion="$(var.InstallerMinorVersion)" ?>
<?define BuildVersion="$(var.InstallerBuildVersion)" ?>

这篇关于构建 MSI 文件(wix 项目)时,在文件名(OutputName)中包含 MajorVersion 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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