@@ -16,7 +16,7 @@ When extending the solution build, chain off one of these
16
16
17
17
<Target Name =" Package" DependsOnTargets =" PackageProjects;PackSharedSources" />
18
18
19
- <Target Name =" Test" />
19
+ <Target Name =" Test" DependsOnTargets = " TestProjects " />
20
20
21
21
<Target Name =" Verify" DependsOnTargets =" VerifyPackages" />
22
22
@@ -54,32 +54,58 @@ as they are subject to change.
54
54
Targets: {Target}Solutions
55
55
56
56
Items: Solutions
57
+ Properties: ExcludeSolutions
57
58
58
59
Executes /t:{Target} on all solutions
59
60
###################################################################
60
61
-->
61
- <Target Name =" CleanSolutions" >
62
+ <PropertyGroup >
63
+ <_SolutionWasBuilt >false</_SolutionWasBuilt >
64
+ <!-- ensure its value doesn't invalidate MSBuild build cache -->
65
+ <_BuildPropertiesToRemove >$(_BuildPropertiesToRemove);_SolutionWasBuilt</_BuildPropertiesToRemove >
66
+
67
+ <BuildInParallel >true</BuildInParallel >
68
+ </PropertyGroup >
69
+
70
+ <Target Name =" _GetSolutions" Condition =" '$(Solutions)'==''" >
71
+ <ItemGroup >
72
+ <Solutions Include =" $(RepositoryRoot)\*.sln" Exclude =" $(ExcludeSolutions)" />
73
+ </ItemGroup >
74
+ </Target >
75
+
76
+ <Target Name =" CleanSolutions" DependsOnTargets =" _GetSolutions" >
62
77
<MSBuild Targets =" Clean"
63
78
Projects =" @(Solutions)"
64
79
Properties =" Configuration=$(Configuration)" />
65
80
</Target >
66
81
67
- <Target Name =" RestoreSolutions" >
82
+ <Target Name =" RestoreSolutions" DependsOnTargets = " _GetSolutions " >
68
83
<MSBuild Targets =" Restore"
69
84
Projects =" @(Solutions)"
70
85
Properties =" Configuration=$(Configuration)" />
71
86
</Target >
72
87
73
- <Target Name =" BuildSolutions" >
88
+ <Target Name =" BuildSolutions" DependsOnTargets = " _GetSolutions " >
74
89
<MSBuild Targets =" Build"
75
90
Projects =" @(Solutions)"
76
- Properties =" Configuration=$(Configuration)" />
91
+ Properties =" Configuration=$(Configuration)"
92
+ BuildInParallel =" $(BuildInParallel)"
93
+ RemoveProperties =" $(_BuildPropertiesToRemove)" />
94
+
95
+ <PropertyGroup >
96
+ <_SolutionWasBuilt >true</_SolutionWasBuilt >
97
+ </PropertyGroup >
77
98
</Target >
78
99
79
- <Target Name =" RebuildSolutions" >
100
+ <Target Name =" RebuildSolutions" DependsOnTargets = " _GetSolutions " >
80
101
<MSBuild Targets =" Rebuild"
81
102
Projects =" @(Solutions)"
82
- Properties =" Configuration=$(Configuration)" />
103
+ Properties =" Configuration=$(Configuration)"
104
+ RemoveProperties =" $(_BuildPropertiesToRemove)" />
105
+
106
+ <PropertyGroup >
107
+ <_SolutionWasBuilt >true</_SolutionWasBuilt >
108
+ </PropertyGroup >
83
109
</Target >
84
110
85
111
<!--
@@ -96,9 +122,15 @@ Executes /t:Pack on all projects matching src/*/*.csproj.
96
122
<ProjectsToPack Condition =" '$(ProjectsToPack)' == ''" Include =" $(RepositoryRoot)src\*\*.csproj" />
97
123
</ItemGroup >
98
124
125
+ <PropertyGroup >
126
+ <PackageNoBuild Condition =" '$(PackageNoBuild)' == ''" >$(_SolutionWasBuilt)</PackageNoBuild >
127
+ </PropertyGroup >
128
+
99
129
<MSBuild Targets =" Pack"
100
130
Projects =" @(ProjectsToPack)"
101
- Properties =" Configuration=$(Configuration);PackageOutputPath=$(BuildDir);NoBuild=true" />
131
+ Properties =" Configuration=$(Configuration);PackageOutputPath=$(BuildDir);NoBuild=$(PackageNoBuild)"
132
+ BuildInParallel =" $(BuildInParallel)"
133
+ RemoveProperties =" $(_BuildPropertiesToRemove);PackageNoBuild" />
102
134
</Target >
103
135
104
136
<!--
@@ -125,9 +157,58 @@ that matches "$(RepositoryRoot)/shared/*.Sources".
125
157
<MSBuild Targets =" Pack"
126
158
Projects =" $(MSBuildThisFileDirectory)..\shared\sharedsources.csproj"
127
159
Properties =" PackageOutputPath=$(BuildDir);RepositoryRoot=$(RepositoryRoot);NuspecBasePath=%(SharedSourceDirectories.Identity);PackageId=%(FileName)%(Extension)"
128
- Condition =" '@(SharedSourceDirectories)'!=''" />
160
+ Condition =" '@(SharedSourceDirectories)'!=''"
161
+ BuildInParallel =" $(BuildInParallel)" />
162
+ </Target >
163
+
164
+ <!--
165
+ ###################################################################
166
+ Target: TestProjects
167
+
168
+ Items: TestProjects. Defaults to test/*/*.csproj
169
+ Properties: ExcludeFromTest. ItemSpec for projects to avoid testing.
170
+
171
+ Runs the VSTest on all projects in the TestProjects itemgroup.
172
+ ###################################################################
173
+ -->
174
+
175
+ <PropertyGroup >
176
+ <!-- TODO if VS Test doesn't make minimal output the default log setting, we can set that here. cref https://github.com/Microsoft/vstest/issues/301 -->
177
+ <VSTestLogger Condition =" '$(VSTestLogger)'=='' AND '$(TEAMCITY_VERSION)' != '' " >trx</VSTestLogger >
178
+ <IgnoreFailingTestProjects >false</IgnoreFailingTestProjects >
179
+ <ContinueOnTestError Condition =" '$(KOREBUILD_IGNORE_DOTNET_TEST_EXIT_CODE)' == '1'" >true</ContinueOnTestError >
180
+
181
+ <!-- experimental flag to see if running test projects in parallel works -->
182
+ <TestInParallel Condition =" '$(TestInParallel)' == ''" >false</TestInParallel >
183
+ </PropertyGroup >
184
+
185
+ <Target Name =" TestProjects" >
186
+
187
+ <ItemGroup Condition =" '@(TestProjects)'==''" >
188
+ <!-- put unit test projects ahead of functional tests -->
189
+ <TestProjects Include =" $(RepositoryRoot)test\*\*.Tests.csproj" Exclude =" $(ExcludeFromTest)" />
190
+ <TestProjects Include =" $(RepositoryRoot)test\*\*.Test.csproj" Exclude =" $(ExcludeFromTest)" />
191
+ <TestProjects Include =" $(RepositoryRoot)test\*\*.csproj" Exclude =" @(TestProjects);$(ExcludeFromTest)" />
192
+ </ItemGroup >
193
+
194
+ <PropertyGroup >
195
+ <VSTestNoBuild Condition =" '$(VSTestNoBuild)' == ''" >$(_SolutionWasBuilt)</VSTestNoBuild >
196
+ <_TestContinueOnError Condition =" '$(IgnoreFailingTestProjects)' == 'true'" >ErrorAndContinue</_TestContinueOnError >
197
+ <_TestContinueOnError Condition =" '$(IgnoreFailingTestProjects)' != 'true'" >ErrorAndStop</_TestContinueOnError >
198
+ </PropertyGroup >
199
+
200
+ <!-- Intentional use of batching ('%') instead of passing items ('@') so that tests fail sooner -->
201
+ <MSBuild Projects =" %(TestProjects.Identity)"
202
+ Targets =" VSTest"
203
+ Properties =" Configurationf=$(Configuration);VSTestLogger=$(VSTestLogger);VSTestNoBuild=$(VSTestNoBuild)"
204
+ Condition =" '@(TestProjects)'!=''"
205
+ ContinueOnError =" $(_TestContinueOnError)"
206
+ BuildInParallel =" $(TestInParallel)"
207
+ RemoveProperties =" $(_BuildPropertiesToRemove);_TestContinueOnError" />
208
+
129
209
</Target >
130
210
211
+
131
212
<!--
132
213
###################################################################
133
214
Target: VerifyPackages
0 commit comments