各种MSBuild版本属性(例如Version,VersionPrefix和VersionSuffix)之间有什么区别? [英] What is the difference between various MSBuild version properties, such as Version, VersionPrefix, and VersionSuffix?

查看:1086
本文介绍了各种MSBuild版本属性(例如Version,VersionPrefix和VersionSuffix)之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MSBuild 15和Microsoft.NET.Sdk构建项目使用户可以指定六个版本属性.两者之间有什么区别,正确的使用方式是什么?

Building projects with MSBuild 15 and Microsoft.NET.Sdk allows users to specify half a dozen version properties. What is the difference between each of these and what is the right way to use them?

  • 版本
  • VersionPrefix
  • 版本后缀
  • AssemblyVersion
  • FileVersion
  • PackageVersion

为了清楚起见,我所说的属性"是文件中定义的MSBuild属性(如下所示)

And to be clear, I'm talking about "properties" as MSBuild properties that are defined in the file (as below)

<PropertyGroup>
   <Version>1.2.0</Version>
</PropertyGroup>

...或在命令行上显示为msbuild.exe /p:Version=1.2.0

...or on command line as msbuild.exe /p:Version=1.2.0

推荐答案

此外,显式设置这些值将覆盖默认值.

Also, setting these values explicitly will override the defaults.

VersionPrefix

格式: major.minor.patch

Format: major.minor.patch

示例: 14.2.4、0.1.0、99.99.99

Examples: 14.2.4, 0.1.0, 99.99.99

含义:semver版本号的正常部分.这用于确定版本值的开头.

Meaning: The normal part of the semver version number. This is used to determine the beginning of the Version value.

默认值:"1.0.0"

版本后缀

格式:[0-9A-Za-z-.] *(任意字符串)

Format: [0-9A-Za-z-.]* (arbitrary string)

示例:alpha,beta,build0123,rc4-build201701,rc.1,rc-1

Examples: alpha, beta, build0123, rc4-build201701, rc.1, rc-1

含义:版本号的预发布标签.用于确定版本值的结尾.

Meaning: The pre-release label of the version number. Used to determine the ending of a Version value.

默认 :(空)

版本

格式: major.minor.patch [-prerelease]

Format: major.minor.patch[-prerelease]

示例:5.3.9-beta,0.0.1-alpha-01、0.0.1-alpha.1、2.0.0

Examples: 5.3.9-beta, 0.0.1-alpha-01, 0.0.1-alpha.1, 2.0.0

含义:此属性是用户项目中最常用的属性.其他版本属性将默认使用此值.它还用于生成System.Reflection.AssemblyInformationalVersionAttribute的值. preprelease值是可选的.

Meaning: This property is the most commonly used property in user projects. Other version properties look to this value as a default. It is also used to generate the value of System.Reflection.AssemblyInformationalVersionAttribute. The preprelease value is optional.

默认值: VersionPrefix (如果VersionSuffix为空). VersionPrefix-VersionSuffix (如果VersionSuffix不为空).

Default: VersionPrefix if VersionSuffix is empty. VersionPrefix-VersionSuffix if VersionSuffix is not empty.

注意:显式设置版本将覆盖所有 VersionPrefix VersionSuffix 设置.

Note: setting Version explicitly will override any VersionPrefix or VersionSuffix settings.

此外,这通常遵循SemVer规则.有关详情,请参见 http://semver.org/

Also, this typically follows SemVer rules. See http://semver.org/ for details

PackageVersion

格式: major.minor.patch [-prerelease]

Format: major.minor.patch[-prerelease]

含义:用于从MSBuild项目生成NuGet软件包时生成软件包版本.

Meaning: Used to generate the package version when producing a NuGet package from an MSBuild project.

默认:匹配版本

AssemblyVersion

格式: major.minor.patch.revision

Format: major.minor.patch.revision

示例: 4.5.6.2、1.0.0.0

Examples: 4.5.6.2, 1.0.0.0

含义:用于生成System.Reflection.AssemblyVersionAttribute的值.编译器使用它来确定最终的AssemblyVersion值,这是程序集标识的重要组成部分.请参阅 https://msdn.microsoft.com /en-us/library/51ket42z(v=vs.110).aspx#Anchor_0

Meaning: Used to generate the value of System.Reflection.AssemblyVersionAttribute. The compiler uses this to determine the final AssemblyVersion value, an essential part of assembly identity. See https://msdn.microsoft.com/en-us/library/51ket42z(v=vs.110).aspx#Anchor_0

默认:与版本匹配,但不带有预发行标签.

Default: matches Version without the prerelease label.

文件版本

格式 major.minor.patch.buildnumber

Format major.minor.patch.buildnumber

示例:1.0.0.43952,0.1.0.0

Examples: 1.0.0.43952, 0.1.0.0

含义:用于生成System.Reflection.AssemblyFileVersionAttribute的值.不需要该名称来匹配AssemblyVersion.通常会在此版本中添加内部版本号.

Meaning: Used to generate the value of System.Reflection.AssemblyFileVersionAttribute. This is not required to match AssemblyVersion. It is common to add a build number to this version.

默认:匹配 AssemblyVersion

InformationalVersion

格式:任意

含义:用于生成System.Reflection.AssemblyInformationalVersionAttribute的值.此属性可以包含任何其他版本信息.

Meaning: Used to generate the value of System.Reflection.AssemblyInformationalVersionAttribute. This attribute can contain any additional version information.

默认:匹配版本

这篇关于各种MSBuild版本属性(例如Version,VersionPrefix和VersionSuffix)之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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