-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
version.targets
86 lines (78 loc) · 4.72 KB
/
version.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- TODO: This should really come from project type, but this will disappear once we get
.NET Standard projects and non /clr bindings -->
<WriteAssemblyInfoCs Condition="'$(WriteAssemblyInfoCs)'==''">false</WriteAssemblyInfoCs>
<WriteAssemblyInfoCpp Condition="'$(WriteAssemblyInfoCpp)'==''">false</WriteAssemblyInfoCpp>
<WriteResourceRc Condition="'$(WriteResourceRc)'==''">false</WriteResourceRc>
</PropertyGroup>
<PropertyGroup>
<AssemblyConfiguration></AssemblyConfiguration>
<AssemblyCompany>Microsoft Corp</AssemblyCompany>
<AssemblyProduct>Vowpal Wabbit</AssemblyProduct>
<CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
<AssemblyCopyright>Copyright (C) Microsoft Corp 2012-$(CurrentYear), Yahoo! Inc. 2007-2012, and many individual contributors. All rights reserved</AssemblyCopyright>
</PropertyGroup>
<ItemGroup>
<VersionFile Include="$(MSBuildThisFileDirectory)..\version.txt" />
</ItemGroup>
<Target Name="ReadVersion">
<ReadLinesFromFile File="@(VersionFile)" >
<Output TaskParameter="Lines" ItemName="VWVersionFileItems" />
</ReadLinesFromFile>
<PropertyGroup>
<VowpalWabbitAssemblyVersion>@(VWVersionFileItems, ' ')</VowpalWabbitAssemblyVersion>
<VowpalWabbitAssemblyVersion>$(VowpalWabbitAssemblyVersion.Trim())</VowpalWabbitAssemblyVersion>
</PropertyGroup>
</Target>
<Target Name="OutputVersion" DependsOnTargets="ReadVersion">
<Message Text="Setting version '$(VowpalWabbitAssemblyVersion)'" />
</Target>
<Target Name="WriteVersionToAssemblyInfoCs" DependsOnTargets="ReadVersion">
<!-- TODO: Get this out of source -->
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"
AssemblyTitle="$(AssemblyTitle)"
AssemblyDescription="$(AssemblyDescription)"
Guid="$(AssemblyGuid)"
AssemblyConfiguration=""
AssemblyCompany="Microsoft Corp"
AssemblyProduct="Vowpal Wabbit"
AssemblyCopyright="$(AssemblyCopyright)"
AssemblyTrademark=""
ComVisible="false"
CLSCompliant="false"
AssemblyVersion="$(VowpalWabbitAssemblyVersion)"
AssemblyFileVersion="$(VowpalWabbitAssemblyVersion)" />
</Target>
<Target Name="WriteVersionToAssemblyInfoCpp" DependsOnTargets="ReadVersion">
<FileUpdate Files="$(MSBuildProjectDirectory)\AssemblyInfo.cpp" Regex="AssemblyVersionAttribute\(".*"\)" ReplacementText="AssemblyVersionAttribute("$(VowpalWabbitAssemblyVersion)")" />
<FileUpdate Files="$(MSBuildProjectDirectory)\AssemblyInfo.cpp" Regex="AssemblyFileVersion\(".*"\)" ReplacementText="AssemblyFileVersion("$(VowpalWabbitAssemblyVersion)")" />
</Target>
<Target Name="WriteVersionToResourceRc" DependsOnTargets="ReadVersion">
<FileUpdate Files="$(MSBuildProjectDirectory)\Resource.rc" Regex="FileVersion".*" ReplacementText="FileVersion", "$(VowpalWabbitAssemblyVersion)"" Encoding="UTF-16" />
<FileUpdate Files="$(MSBuildProjectDirectory)\Resource.rc" Regex="ProductVersion".*" ReplacementText="ProductVersion", "$(VowpalWabbitAssemblyVersion)"" Encoding="UTF-16" />
<FileUpdate Files="$(MSBuildProjectDirectory)\Resource.rc" Regex="FILEVERSION .*" ReplacementText="FILEVERSION $(VowpalWabbitAssemblyVersion.Replace('.',','))" Encoding="UTF-16" />
<FileUpdate Files="$(MSBuildProjectDirectory)\Resource.rc" Regex="PRODUCTVERSION .*" ReplacementText="PRODUCTVERSION $(VowpalWabbitAssemblyVersion.Replace('.',','))" Encoding="UTF-16" />
</Target>
<PropertyGroup>
<WriteTargets>OutputVersion</WriteTargets>
<WriteTargets Condition="'$(WriteAssemblyInfoCs.ToLower())'=='true'">
$(WriteTargets);
WriteVersionToAssemblyInfoCs
</WriteTargets>
<WriteTargets Condition="'$(WriteAssemblyInfoCpp.ToLower())'=='true'">
$(WriteTargets);
WriteVersionToAssemblyInfoCpp
</WriteTargets>
<WriteTargets Condition="'$(WriteResourceRc.ToLower())'=='true'">
$(WriteTargets);
WriteVersionToResourceRc
</WriteTargets>
<BuildDependsOn>
$(WriteTargets);
$(BuildDependsOn);
</BuildDependsOn>
</PropertyGroup>
</Project>