forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.proj
251 lines (212 loc) · 13.8 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Capture OSGroup passed to command line for setting default FilterToOSGroup value below -->
<_OriginalOSGroup>$(OSGroup)</_OriginalOSGroup>
</PropertyGroup>
<PropertyGroup>
<InputOSGroup>$(OSGroup)</InputOSGroup>
<InputOSGroup Condition="'$(InputOSGroup)'==''">$(FilterToOSGroup)</InputOSGroup>
</PropertyGroup>
<Import Project="dir.props" />
<!-- required to build the projects in their specified order -->
<PropertyGroup>
<SerializeProjects>true</SerializeProjects>
</PropertyGroup>
<!-- The following properties are in place to keep the behavior of build.cmd while we work on the dev workflow steps. -->
<PropertyGroup>
<!-- To disable the restoration of packages, set RestoreDuringBuild=false or pass /p:RestoreDuringBuild=false.-->
<RestoreDuringBuild Condition="'$(RestoreDuringBuild)'==''">true</RestoreDuringBuild>
<!-- To disable building packages, set BuildPackages=false or pass /p:BuildPackages=false.-->
<BuildPackages Condition="'$(BuildPackages)'==''">true</BuildPackages>
<!-- To disable building tests, set BuildTests=false or pass /p:BuildTests=false.-->
<BuildTests Condition="'$(BuildTests)'==''">true</BuildTests>
</PropertyGroup>
<PropertyGroup>
<GenerateCodeCoverageReportForAll>true</GenerateCodeCoverageReportForAll>
</PropertyGroup>
<Import Project="$(ToolsDir)CodeCoverage.targets" Condition="Exists('$(ToolsDir)CodeCoverage.targets')" />
<Import Project="$(ToolsDir)PerfTesting.targets" Condition="Exists('$(ToolsDir)PerfTesting.targets') and '$(Performance)' == 'true'"/>
<Import Project="$(ToolsDir)VersionTools.targets" Condition="Exists('$(ToolsDir)VersionTools.targets')" />
<ItemGroup Condition="$(BuildTests)!='true'">
<Project Include="src\dirs.proj">
<!-- For the root traversal default filter the OSGroup to the OSEnvironment which is the OS we are running on -->
<FilterToOSGroup Condition="'$(_OriginalOSGroup)' == ''">$(OSEnvironment)</FilterToOSGroup>
<InputOSGroup>$(InputOSGroup)</InputOSGroup>
</Project>
<!-- signing must happen before packaging -->
<Project Include="src\sign.builds" />
<Project Include="src\packages.builds" Condition="'$(BuildPackages)'=='true'">
<InputOSGroup>$(InputOSGroup)</InputOSGroup>
</Project>
<Project Include="layout\Microsoft.Private.CoreFx.NETCoreApp\Microsoft.Private.CoreFx.NETCoreApp.builds" Condition="'$(BuildPackages)'=='true'">
<InputOSGroup>$(InputOSGroup)</InputOSGroup>
</Project>
<Project Include="src\post.builds">
<!-- For the root traversal default filter the OSGroup to the OSEnvironment which is the OS we are running on -->
<FilterToOSGroup Condition="'$(_OriginalOSGroup)' == ''">$(OSEnvironment)</FilterToOSGroup>
</Project>
</ItemGroup>
<ItemGroup Condition="$(BuildTests)=='true'">
<Project Include="src\tests.builds">
<InputOSGroup>$(InputOSGroup)</InputOSGroup>
</Project>
</ItemGroup>
<Import Project="dir.targets" />
<Import Project="dir.traversal.targets" />
<Import Project="$(ToolsDir)clean.targets" />
<PropertyGroup Condition="'$(RestoreDuringBuild)'=='true'">
<TraversalBuildDependsOn>
BatchRestorePackages;
ValidateExactRestore;
CreateOrUpdateCurrentVersionFile;
$(TraversalBuildDependsOn);
</TraversalBuildDependsOn>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildTestsAgainstPackages)' == 'true'">
<TraversalBuildDependsOn>
UpdateVersionsOnTestProjectJson;
BatchGenerateTestProjectJsons;
$(TraversalBuildDependsOn);
</TraversalBuildDependsOn>
</PropertyGroup>
<!-- Create a collection of all project.json files for dependency updates. -->
<ItemGroup>
<ProjectJsonFiles Condition="'$(ExcludeNonTestRestores)' != 'true'" Include="$(SourceDir)**/project.json" />
<ProjectJsonFiles Condition="'$(ExcludeNonTestRestores)' != 'true'" Include="$(ProjectDir)pkg/**/project.json" />
<ProjectJsonFiles Include="$(MSBuildThisFileDirectory)layout/**/project.json" />
<ProjectJsonFiles Include="$(MSBuildThisFileDirectory)layout/**/project.json" />
<!-- Additional generated ProjectJsonFiles are added in the build.proj target AddGeneratedProjectJsons -->
</ItemGroup>
<ItemGroup>
<TestProjectJsons Include="$(MSBuildThisFileDirectory)src/Common/test-runtime/project.json" />
</ItemGroup>
<PropertyGroup>
<SupportsDefinitionFile>@(SupportsDefinitionFileGroup)</SupportsDefinitionFile>
</PropertyGroup>
<UsingTask TaskName="GatherDirectoriesToRestore" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
<Target Name="BatchRestorePackages" DependsOnTargets="AddGeneratedProjectJsons;VerifyDependencies">
<MakeDir Directories="$(PackagesDir)" Condition="!Exists('$(PackagesDir)')" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages..." />
<IsRestoreRequired ProjectJsons="@(ProjectJsonFiles)" PackagesFolder="$(PackagesDir)">
<Output TaskParameter="RestoreRequired" PropertyName="RestoreRequired" />
</IsRestoreRequired>
<Message Importance="High" Condition="'$(RestoreRequired)' == 'true' and '$(BuildTestsAgainstPackages)' != 'true'" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] $(DnuRestoreCommand) @(TestProjectJsons->'"%(Identity)"', ' ')" />
<!-- This is to restore the test-runtime project.json up front which contains the latest packages to be tested to avoid download contention within nuget. -->
<Exec Command="$(DnuRestoreCommand) @(TestProjectJsons->'"%(Identity)"', ' ')"
Condition="'$(RestoreRequired)' == 'true' and '$(BuildTestsAgainstPackages)' != 'true'"
StandardOutputImportance="Low"
CustomErrorRegularExpression="(^Unable to locate .*)|(^Updating the invalid lock file with .*)"
ContinueOnError="ErrorAndContinue" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] $(DnuRestoreCommand) @(DnuRestoreDir->'"%(Identity)"', ' ')" />
<Exec Command="$(DnuRestoreCommand) @(DnuRestoreDir->'"%(Identity)"', ' ')"
Condition="'$(RestoreRequired)' == 'true'"
StandardOutputImportance="Low"
CustomErrorRegularExpression="(^Unable to locate .*)|(^Updating the invalid lock file with .*)"
ContinueOnError="ErrorAndContinue" />
<!-- Given we ErrorAndContinue we need to propagate the error if the overall task failed -->
<Error Condition="'$(MSBuildLastTaskResult)'=='false'" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages...Done." />
</Target>
<!-- Generated project.json's may not exist when the "ProjectJsonFiles"" item group is defined (in dir.props), This target
ensures those files are added to the itemgroup. -->
<Target Name="AddGeneratedProjectJsons">
<ItemGroup>
<ProjectJsonFiles Condition="'$(BuildTestsAgainstPackages)' == 'true'" Include="$(GeneratedProjectJsonDir)/**/project.json" />
</ItemGroup>
</Target>
<UsingTask TaskName="AddDependenciesToProjectJson" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
<Target Name="UpdateVersionsOnTestProjectJson" DependsOnTargets="GetDefaultTestRid">
<!-- Duplicate properties to be removed in future -->
<ItemGroup>
<_PackagesDropsForCommonProjectJson Include="$(PackagesDrops)" />
</ItemGroup>
<PropertyGroup>
<PackageNameRegex Condition="'$(PackageNameRegex)' == ''">(?%3Cname%3E.*)\.(?%3Cversion%3E\d+\.\d+\.\d+)(-(?%3Cprerelease%3E.*)?)?</PackageNameRegex>
</PropertyGroup>
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Using RuntimeIdentifier = '$(TestNugetRuntimeId)'" />
<PropertyGroup>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'netcoreapp1.0'">.NETCoreApp,Version=v1.0</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'netcoreapp1.1'">.NETCoreApp,Version=v1.1</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net463'">.NETFramework,Version=v4.6.3</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net462'">.NETFramework,Version=v4.6.2</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net461'">.NETFramework,Version=v4.6.1</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net46'">.NETFramework,Version=v4.6</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net45'">.NETFramework,Version=v4.5</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net451'">.NETFramework,Version=v4.5.1</FilterTestNugetTargetMoniker>
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'net452'">.NETFramework,Version=v4.5.2</FilterTestNugetTargetMoniker>
<!-- Project template for UWP Apps uses uap10.0, this mapping allows support for the Debug and Release scenarios -->
<FilterTestNugetTargetMoniker Condition="'$(FilterToTestTFM)' == 'netcore50aot' Or '$(FilterToTestTFM)' == 'netcore50'">UAP,Version=v10.0</FilterTestNugetTargetMoniker>
</PropertyGroup>
<AddDependenciesToProjectJson AdditionalDependencies="@(_InjectProjectReferenceDependency)"
PackagesDrops="@(_PackagesDropsForCommonProjectJson)"
PackageNameRegex="$(PackageNameRegex)"
VersionsFiles="@(_VersionsFiles)"
ProjectJson="$(CommonTestProjectJson)"
OutputProjectJson="$(CommonOutputTestProjectJson)"
UseNewestAvailablePackages="$(UseNewestAvailablePackages)"
SupportsFile="$(CommonTestProjectJson)"
TestRuntime="$(TestNugetRuntimeId)"
TestTargetFramework="$(FilterTestNugetTargetMoniker)"
/>
</Target>
<!-- Evaluate our test projects (in src\tests.builds) -->
<Target Name="BatchGenerateTestProjectJsons"
Condition="'$(BuildTestsAgainstPackages)' == 'true'"
DependsOnTargets="FilterProjects;UpdateVersionsOnTestProjectJson"
BeforeTargets="RestorePackages">
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Generating Test project.json's..." />
<ItemGroup>
<GenerateForProject Include="src\tests.builds">
<UndefineProperties>%(Project.UndefineProperties);OSGroup</UndefineProperties>
</GenerateForProject>
</ItemGroup>
<MSBuild Targets="GenerateAllTestProjectJsons"
Projects="@(GenerateForProject)"
/>
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Generating Test project.json's...done" />
</Target>
<!-- Task from buildtools that uses lockfiles to validate that packages restored are exactly what were specified. -->
<UsingTask TaskName="ValidateExactRestore" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
<Target Name="ValidateExactRestore"
Condition="'$(AllowInexactRestore)'!='true'">
<ValidateExactRestore ProjectLockJsons="@(ProjectJsonFiles->'%(RootDir)%(Directory)%(Filename).lock.json')" />
</Target>
<!-- Tasks from buildtools for easy project.json dependency updates -->
<UsingTask TaskName="UpdatePackageDependencyVersion" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
<Target Name="UpdatePackageDependencyVersion">
<UpdatePackageDependencyVersion ProjectJsons="@(ProjectJsonFiles)"
PackageId="$(PackageId)"
OldVersion="$(OldVersion)"
NewVersion="$(NewVersion)" />
</Target>
<!-- Packages.zip creation -->
<UsingTask TaskName="ZipFileCreateFromDependencyLists" Condition="'$(ArchiveTests)' == 'true'" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
<Target Name="ArchiveTestBuild" Condition="'$(ArchiveTests)' == 'true'" AfterTargets="Build" >
<ItemGroup>
<ExcludeFromArchive Include="nupkg$" />
<ExcludeFromArchive Include="Microsoft.DotNet.BuildTools" />
<ExcludeFromArchive Include="TestData" />
<TestDependencyListFile Include="$(BinDir)/TestDependencies/*.dependencylist.txt" />
</ItemGroup>
<PropertyGroup>
<TestArchiveDir>$(TestWorkingDir)$(OSPlatformConfig)/archive/tests/</TestArchiveDir>
<TestArchiveDir Condition="'$(TestTFM)' != ''">$(TestArchiveDir)$(TestTFM)/</TestArchiveDir>
</PropertyGroup>
<ZipFileCreateFromDependencyLists
DependencyListFiles="@(TestDependencyListFile)"
DestinationArchive="$(TestArchiveDir)\Packages.zip"
RelativePathBaseDirectory="$(PackagesDir)"
OverwriteDestination="true" />
</Target>
<!-- Override RestorePackages from dir.traversal.targets and do a batch restore -->
<Target Name="RestorePackages" DependsOnTargets="BatchRestorePackages" />
<!-- Override CleanAllProjects from dir.traversal.targets and just remove the full BinDir -->
<Target Name="CleanAllProjects">
<RemoveDir Directories="$(BinDir)" />
<!-- Temporarily outside BinDir -->
<RemoveDir Directories="$(PackageInstallPath)" />
</Target>
<!-- Hook that can be used to insert custom build tasks to the build process such as setup and/or cleanup tasks -->
<Import Project="build.override.targets" Condition="Exists('build.override.targets')" />
</Project>