-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.proj
199 lines (160 loc) · 7.86 KB
/
build.proj
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?xml version="1.0" encoding="utf-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2015 Mobile Essentials
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<TrackFileAccess>false</TrackFileAccess>
<VersionFormat Condition="'$(VersionFormat)' == ''">MAJOR.MINOR.PATCH</VersionFormat>
</PropertyGroup>
<ItemGroup>
<!-- To build a single solution or project, just pass it as a property $(Solution) or $(Project) -->
<!-- Solutions at the root of the src directory are all built automatically unless overriden -->
<Solution Include="src\*.sln" Condition="'$(Solution)' == ''">
<AdditionalProperties>Configuration=$(Configuration);TrackFileAccess=$(TrackFileAccess)</AdditionalProperties>
</Solution>
<Solution Include="$(Solution)" Condition="'$(Solution)' != ''">
<AdditionalProperties>Configuration=$(Configuration);TrackFileAccess=$(TrackFileAccess)</AdditionalProperties>
</Solution>
<NuGet Include="**\*.nuspec" />
</ItemGroup>
<Import Project="build\build.targets" />
<Import Project="packages\MSBuilder.CodeTaskAssembly\build\MSBuilder.CodeTaskAssembly.props" />
<Import Project="packages\MSBuilder.Git\build\MSBuilder.Git.props" />
<Import Project="packages\MSBuilder.Run\build\MSBuilder.Run.targets" />
<Import Project="packages\MSBuilder.NuGet.GetLatestVersion\build\MSBuilder.NuGet.GetLatestVersion.tasks" />
<PropertyGroup>
<!-- We overwrite the prop since we don't want FormatVersion at all -->
<BuildPackagesDependsOn>
$(BuildPackagesDependsOn);
AddPackageMetadata;
FilterPackages;
</BuildPackagesDependsOn>
</PropertyGroup>
<Target Name="Test" DependsOnTargets="CoreBuild" AfterTargets="CoreBuild">
<PropertyGroup>
<XunitConsole>packages\xunit.runner.console\tools\xunit.console.x86.exe</XunitConsole>
<XunitOptions>$(XunitOptions) -noshadow</XunitOptions>
</PropertyGroup>
<ItemGroup>
<TestProject Include="$(SourceDir)**\*.Tests.csproj" Condition=" '$(TestProject)' == '' " />
<TestProject Include="$(TestProject)" Condition=" '$(TestProject)' != '' " />
</ItemGroup>
<MSBuild Projects="@(TestProject)" BuildInParallel="true" Properties="Configuration=$(Configuration)" Targets="GetTargetPath"
Condition="'%(TestProject.FileName)' != 'Roslyn.Tests' and '%(TestProject.FileName)' != 'VsixInstaller.Tests'">
<!-- Roslyn.Tests fails randomly on CI, but work locally, VsixInstaller.Tests takes forever and sometimes hangs the build -->
<Output TaskParameter="TargetOutputs" ItemName="_TestAssembly" />
</MSBuild>
<ItemGroup>
<TestAssembly Include="@(_TestAssembly)" Condition=" Exists('%(_TestAssembly.FullPath)') " />
</ItemGroup>
<Exec Command="$(XunitConsole) %(TestAssembly.FullPath) $(XunitOptions)"
Condition=" '@(TestAssembly)' != '' "
ConsoleToMSBuild="true"
WorkingDirectory="$(MSBuildThisFileDirectory)"
ContinueOnError="ErrorAndContinue" />
<!--<xunit Assemblies="@(TestAssembly)"
Html="out\tests.html"
Xml="out\tests.xml"
ParallelizeAssemblies="$(ParallelizeAssemblies)"
ParallelizeTestCollections="$(ParallelizeTestCollections)" />-->
</Target>
<Target Name="FilterPackages" Inputs="@(NuGet)" Outputs="%(NuGet.Identity)-BATCH">
<GetLatestVersion PackageId="%(NuGet.Id)" IncludePreRelease="true">
<Output TaskParameter="SimpleVersion" PropertyName="LatestVersion" />
</GetLatestVersion>
<CompareVersions Current="%(NuGet.Version)" Latest="$(LatestVersion)">
<Output TaskParameter="Result" PropertyName="Comparison" />
</CompareVersions>
<IncrementVersion Version="$(LatestVersion)" Commits="1" Condition="'$(Comparison)' == '-1'">
<Output TaskParameter="Result" PropertyName="SuggestedVersion" />
</IncrementVersion>
<Message Text="Skipping '%(NuGet.Id)': %(NuGet.Version) == $(LatestVersion) (current == latest)" Importance="normal" Condition="'$(Comparison)' == '0'" />
<Message Text="Updated '%(NuGet.Id)': %(NuGet.Version) > $(LatestVersion) (current > latest!)" Importance="high" Condition="'$(Comparison)' == '1'" />
<Error Text="Currently determined package version for '%(NuGet.Id)' is %(NuGet.Version), which is smaller than the latest published version $(LatestVersion).
This is an authoring error that typically indicates that a change was made to the .nuspec file without changing the version to be greater than the latest published version.
Change the 'version' attribute to be at least '$(SuggestedVersion)' (or increase the major or minor components)." Condition="'$(Comparison)' == '-1'" />
<ItemGroup>
<NuGet Remove="@(NuGet)" Condition="$(Comparison) == '0'" />
</ItemGroup>
</Target>
<Target Name="AddPackageMetadata" Inputs="@(NuGet)" Outputs="%(NuGet.Identity)-BATCH">
<PropertyGroup>
<NuSpec>%(NuGet.Identity)</NuSpec>
</PropertyGroup>
<Run Exe='$(Git)'
Args='log -n 1 --pretty=format:%H "$(NuSpec)"'
WorkingDir='$(MSBuildProjectDirectory)'>
<Output TaskParameter="Output" PropertyName="NuSpecSha" />
</Run>
<Run Exe='$(Git)'
Args='rev-list --count "$(NuSpecSha)"..HEAD $([System.IO.Path]::GetDirectoryName("$(NuSpec)"))'
WorkingDir='$(MSBuildProjectDirectory)'>
<Output TaskParameter="Output" PropertyName="NuSpecCommits" />
</Run>
<XmlPeek XmlInputPath="$(NuSpec)"
Query="/package/metadata/id/text()">
<Output TaskParameter="Result" PropertyName="NuSpecId" />
</XmlPeek>
<XmlPeek XmlInputPath="$(NuSpec)"
Query="/package/metadata/version/text()">
<Output TaskParameter="Result" PropertyName="NuSpecVersion" />
</XmlPeek>
<IncrementVersion Version="$(NuSpecVersion)" Commits="$(NuSpecCommits)">
<Output TaskParameter="Result" PropertyName="NuSpecVersion" />
</IncrementVersion>
<ItemGroup>
<NuGet>
<Id>$(NuSpecId)</Id>
<Commits>$(NuSpecCommits)</Commits>
<Version>$(NuSpecVersion)</Version>
</NuGet>
</ItemGroup>
</Target>
<UsingTask TaskName="IncrementVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskAssembly)">
<ParameterGroup>
<Version Required="true"/>
<Commits Required="false" ParameterType="System.Int32" />
<Result Output="true"/>
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
var version = new Version(Version);
Result = new Version(version.Major, version.Minor, (version.Build != -1 ? version.Build : 0) + Commits).ToString();
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="CompareVersions" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskAssembly)">
<ParameterGroup>
<Current Required="true"/>
<Latest Required="true" />
<Result Output="true"/>
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
Result = new Version(Current).CompareTo(new Version(Latest)).ToString();
]]>
</Code>
</Task>
</UsingTask>
</Project>