在MSbuild生成期间获取项目版本信息
我正试图通过MSBuild自动化安装程序的构建。我遇到的问题是获取调用自定义MSBuild脚本的C#项目的版本信息,该脚本将在生成过程中将版本号传递到Wix 我想做的是将版本设置为以下属性:在MSbuild生成期间获取项目版本信息,msbuild,continuous-integration,version,Msbuild,Continuous Integration,Version,我正试图通过MSBuild自动化安装程序的构建。我遇到的问题是获取调用自定义MSBuild脚本的C#项目的版本信息,该脚本将在生成过程中将版本号传递到Wix 我想做的是将版本设置为以下属性: <ProductVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion).$(BuildVersion)</ProductVersion> <InstallerName>"$(ProductName)-$(Produc
<ProductVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion).$(BuildVersion)</ProductVersion>
<InstallerName>"$(ProductName)-$(ProductVersion).msi"</InstallerName>
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion="4.0"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Include the version info file so that we can pull the version info from it -->
<Import
Project="$(DirWorkspace)\version.xml"
Condition="Exists('$(DirWorkspace)\version.xml')" />
<!-- Generate a file with the version information -->
<Target Name="GenerateAssemblyInfoVersionNumber">
<ItemGroup>
<VersionTokens Include="Major">
<ReplacementValue>$(VersionMajor)</ReplacementValue>
</VersionTokens>
<VersionTokens Include="Minor">
<ReplacementValue>$(VersionMinor)</ReplacementValue>
</VersionTokens>
<VersionTokens Include="Build">
<ReplacementValue>$(VersionBuild)</ReplacementValue>
</VersionTokens>
<VersionTokens Include="Revision">
<ReplacementValue>$(VersionRevision)</ReplacementValue>
</VersionTokens>
</ItemGroup>
<TemplateFile
Template="$(FileTemplateAssemblyVersion)"
OutputFileName="$(FileGeneratedAssemblyVersion)"
Tokens="@(VersionTokens)" />
</Target>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--
This is a generated file.
Do NOT make changes to this file.
They will be undone next time the file is generated.
-->
<!-- The current version -->
<?define CurrentVersion = "${Major}.${Minor}.${Build}"?>
<!-- The install version string -->
<?define ProductVersionFolder = "${Major}.${Minor}"?>
</Include>
$(主版本)。$(MinorVersion)。$(补丁版本)。$(构建版本)
“$(ProductName)-$(ProductVersion).msi”
该版本作为我们的持续集成构建的一部分进行更新,并将版本号合并到构建在我们的持续集成服务器上的每个安装程序中,以帮助我们生成可持续部署的应用程序
任何帮助都将不胜感激。我解决这个问题的方法是在代码库中创建一个“version.xml”文件。此文件包含以下数据
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionBuild>1</VersionBuild>
<VersionRevision>0</VersionRevision>
</PropertyGroup>
</Project>
包含此文件后,可以在需要时参考Wix安装程序中的CurrentVersion
和ProductVersionFolder
变量
通过使用此方法,版本信息存储在单个位置,并且可以被构建的所有部分访问
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--
This is a generated file.
Do NOT make changes to this file.
They will be undone next time the file is generated.
-->
<!-- The current version -->
<?define CurrentVersion = "${Major}.${Minor}.${Build}"?>
<!-- The install version string -->
<?define ProductVersionFolder = "${Major}.${Minor}"?>
</Include>