@@ -123,6 +123,161 @@ public void BuildProjectAsTarget()
123
123
}
124
124
}
125
125
126
+ /// <summary>
127
+ /// Build Solution with Multiple Targets (ex. Clean;Build;Custom).
128
+ /// </summary>
129
+ [ Fact ]
130
+ public void BuildProjectWithMultipleTargets ( )
131
+ {
132
+ using ( TestEnvironment testEnvironment = TestEnvironment . Create ( ) )
133
+ {
134
+ TransientTestFolder folder = testEnvironment . CreateFolder ( createFolder : true ) ;
135
+ TransientTestFolder classLibFolder = testEnvironment . CreateFolder ( Path . Combine ( folder . Path , "classlib" ) , createFolder : true ) ;
136
+ TransientTestFile classLibrary = testEnvironment . CreateFile ( classLibFolder , "classlib.csproj" ,
137
+ @"<Project>
138
+ <Target Name=""Build"">
139
+ <Message Text=""classlib.Build""/>
140
+ </Target>
141
+ <Target Name=""Clean"">
142
+ <Message Text=""classlib.Clean""/>
143
+ </Target>
144
+ <Target Name=""Custom"">
145
+ <Message Text=""classlib.Custom""/>
146
+ </Target>
147
+ </Project>
148
+ " ) ;
149
+
150
+ TransientTestFolder simpleProjectFolder = testEnvironment . CreateFolder ( Path . Combine ( folder . Path , "simpleProject" ) , createFolder : true ) ;
151
+ TransientTestFile simpleProject = testEnvironment . CreateFile ( simpleProjectFolder , "simpleProject.csproj" ,
152
+ @"<Project>
153
+ <Target Name=""Build"">
154
+ <Message Text=""simpleProject.Build""/>
155
+ </Target>
156
+ <Target Name=""Clean"">
157
+ <Message Text=""simpleProject.Clean""/>
158
+ </Target>
159
+ <Target Name=""Custom"">
160
+ <Message Text=""simpleProject.Custom""/>
161
+ </Target>
162
+ </Project>
163
+ " ) ;
164
+
165
+ TransientTestFile solutionFile = testEnvironment . CreateFile ( folder , "testFolder.sln" ,
166
+ @"
167
+ Microsoft Visual Studio Solution File, Format Version 12.00
168
+ # Visual Studio Version 16
169
+ VisualStudioVersion = 16.6.30114.105
170
+ MinimumVisualStudioVersion = 10.0.40219.1
171
+ Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""simpleProject"", ""simpleProject\simpleProject.csproj"", ""{AA52A05F-A9C0-4C89-9933-BF976A304C91}""
172
+ EndProject
173
+ Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""classlib"", ""classlib\classlib.csproj"", ""{80B8E6B8-E46D-4456-91B1-848FD35C4AB9}""
174
+ EndProject
175
+ Global
176
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
177
+ Debug|x86 = Debug|x86
178
+ EndGlobalSection
179
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
180
+ {AA52A05F-A9C0-4C89-9933-BF976A304C91}.Debug|x86.ActiveCfg = Debug|x86
181
+ {AA52A05F-A9C0-4C89-9933-BF976A304C91}.Debug|x86.Build.0 = Debug|x86
182
+ {80B8E6B8-E46D-4456-91B1-848FD35C4AB9}.Debug|x86.ActiveCfg = Debug|x86
183
+ {80B8E6B8-E46D-4456-91B1-848FD35C4AB9}.Debug|x86.Build.0 = Debug|x86
184
+ EndGlobalSection
185
+ EndGlobal
186
+ " ) ;
187
+
188
+ string output = RunnerUtilities . ExecMSBuild ( solutionFile . Path + " /t:Clean;Build;Custom" , out bool success ) ;
189
+ success . ShouldBeTrue ( ) ;
190
+ output . ShouldContain ( "classlib.Build" ) ;
191
+ output . ShouldContain ( "classlib.Clean" ) ;
192
+ output . ShouldContain ( "classlib.Custom" ) ;
193
+ output . ShouldContain ( "simpleProject.Build" ) ;
194
+ output . ShouldContain ( "simpleProject.Clean" ) ;
195
+ output . ShouldContain ( "simpleProject.Custom" ) ;
196
+ }
197
+ }
198
+
199
+
200
+ /// <summary>
201
+ /// Build Solution with Multiple Targets (ex. Clean;Build;Custom).
202
+ /// </summary>
203
+ [ Fact ]
204
+ public void BuildProjectWithMultipleTargetsInParallel ( )
205
+ {
206
+ using ( TestEnvironment testEnvironment = TestEnvironment . Create ( ) )
207
+ {
208
+ TransientTestFolder folder = testEnvironment . CreateFolder ( createFolder : true ) ;
209
+ TransientTestFolder classLibFolder = testEnvironment . CreateFolder ( Path . Combine ( folder . Path , "classlib" ) , createFolder : true ) ;
210
+ TransientTestFile classLibrary = testEnvironment . CreateFile ( classLibFolder , "classlib.csproj" ,
211
+ @"<Project>
212
+ <Target Name=""Build"">
213
+ <Message Text=""classlib.Build""/>
214
+ </Target>
215
+ <Target Name=""Clean"">
216
+ <Message Text=""classlib.Clean""/>
217
+ </Target>
218
+ <Target Name=""Custom"">
219
+ <Message Text=""classlib.Custom""/>
220
+ </Target>
221
+ </Project>
222
+ " ) ;
223
+
224
+ TransientTestFolder simpleProjectFolder = testEnvironment . CreateFolder ( Path . Combine ( folder . Path , "simpleProject" ) , createFolder : true ) ;
225
+ TransientTestFile simpleProject = testEnvironment . CreateFile ( simpleProjectFolder , "simpleProject.csproj" ,
226
+ @"<Project>
227
+ <Target Name=""Build"">
228
+ <Message Text=""simpleProject.Build""/>
229
+ </Target>
230
+ <Target Name=""Clean"">
231
+ <Message Text=""simpleProject.Clean""/>
232
+ </Target>
233
+ <Target Name=""Custom"">
234
+ <Message Text=""simpleProject.Custom""/>
235
+ </Target>
236
+ </Project>
237
+ " ) ;
238
+
239
+ TransientTestFile solutionFile = testEnvironment . CreateFile ( folder , "testFolder.sln" ,
240
+ @"
241
+ Microsoft Visual Studio Solution File, Format Version 12.00
242
+ # Visual Studio Version 16
243
+ VisualStudioVersion = 16.6.30114.105
244
+ MinimumVisualStudioVersion = 10.0.40219.1
245
+ Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""simpleProject"", ""simpleProject\simpleProject.csproj"", ""{AA52A05F-A9C0-4C89-9933-BF976A304C91}""
246
+ EndProject
247
+ Project(""{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"") = ""classlib"", ""classlib\classlib.csproj"", ""{80B8E6B8-E46D-4456-91B1-848FD35C4AB9}""
248
+ EndProject
249
+ Global
250
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
251
+ Debug|x86 = Debug|x86
252
+ EndGlobalSection
253
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
254
+ {AA52A05F-A9C0-4C89-9933-BF976A304C91}.Debug|x86.ActiveCfg = Debug|x86
255
+ {AA52A05F-A9C0-4C89-9933-BF976A304C91}.Debug|x86.Build.0 = Debug|x86
256
+ {80B8E6B8-E46D-4456-91B1-848FD35C4AB9}.Debug|x86.ActiveCfg = Debug|x86
257
+ {80B8E6B8-E46D-4456-91B1-848FD35C4AB9}.Debug|x86.Build.0 = Debug|x86
258
+ EndGlobalSection
259
+ EndGlobal
260
+ " ) ;
261
+
262
+ try
263
+ {
264
+ Environment . SetEnvironmentVariable ( "MSBuildSolutionBatchTargets" , "1" ) ;
265
+ var output = RunnerUtilities . ExecMSBuild ( solutionFile . Path + " /m /t:Clean;Build;Custom" , out bool success ) ;
266
+ success . ShouldBeTrue ( ) ;
267
+ output . ShouldContain ( "classlib.Build" ) ;
268
+ output . ShouldContain ( "classlib.Clean" ) ;
269
+ output . ShouldContain ( "classlib.Custom" ) ;
270
+ output . ShouldContain ( "simpleProject.Build" ) ;
271
+ output . ShouldContain ( "simpleProject.Clean" ) ;
272
+ output . ShouldContain ( "simpleProject.Custom" ) ;
273
+ }
274
+ finally
275
+ {
276
+ Environment . SetEnvironmentVariable ( "MSBuildSolutionBatchTargets" , "" ) ;
277
+ }
278
+ }
279
+ }
280
+
126
281
/// <summary>
127
282
/// Verify the AddNewErrorWarningMessageElement method
128
283
/// </summary>
0 commit comments