이 문제를 해결 한 방법은 내 코드 저장소에 '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>
을 포함하지만, 빌드 서버에서 정보 또는 무엇이든 요구되는이 파일을 생성하기 위해 너무 열심히해서는 안됩니다.
빌드하는 동안 사용자 지정 MsBuild taks (TemplateFile task과 유사)는 각각의 템플릿 파일에서 어셈블리 정보 파일과 Wix 포함 파일을 만듭니다. 'version.xml'파일은 MsBuild 스크립트에 포함시켜 액세스 할 수 있습니다. 이와 같은 예를 들어
는 C# 프로젝트에 포함 된 AssemblyInfo.VersionNumber.cs 파일과 같은 템플릿 파일로부터 생성
<?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>
: 교체 과정
//-----------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost
// if the code is regenerated.
// </auto-generated>
//-----------------------------------------------------------------------
using System.Reflection;
[assembly: AssemblyVersion("${Major}.${Minor}.${Build}.${Revision}")]
[assembly: AssemblyFileVersion("${Major}.${Minor}.${Build}.${Revision}")]
// The AssemblyInformationalVersion stores the version that will be displayed in
// Windows explorer.
[assembly: AssemblyInformationalVersion("${Major}.${Minor}.${Build}.${Revision}")]
${TEXT_HERE}
부 는 각각의 값으로 대체됩니다.
<?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>
을가 CurrentVersion
과 필요 이제까지 윅스 설치의 ProductVersionFolder
변수를 참조 할 수있다이 파일을 포함한 후 :
윅스
는 템플릿 파일은 다음과 같습니다 포함한다.
이 방법을 사용하면 버전 정보가 단일 위치에 저장되고 빌드의 모든 부분에서 액세스 할 수 있습니다.