Skip to content

Commit 8195275

Browse files
yhviceyjeffkl
authored andcommitted
Add support for command dotnet test and dotnet publish (#54)
1 parent 4f012e2 commit 8195275

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed

src/Traversal.UnitTests/TraversalTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public void SkipsNonExistentTargets()
7575
[InlineData("Clean")]
7676
[InlineData("Build")]
7777
[InlineData("Test")]
78+
[InlineData("VSTest")]
7879
[InlineData("Pack")]
80+
[InlineData("Publish")]
7981
public void TraversalTargetsRun(string target)
8082
{
8183
string[] projects = new[]

src/Traversal/Sdk/Sdk.targets

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
33
Copyright (c) Microsoft Corporation. All rights reserved.
4-
4+
55
Licensed under the MIT license.
66
-->
77
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
@@ -17,7 +17,7 @@
1717
<OutputPath Condition=" '$(Configuration)' != '' And '$(Platform)' == '' ">bin\$(Configuration)\</OutputPath>
1818
<OutputPath Condition=" '$(Configuration)' != '' And '$(Platform)' != '' ">bin\$(Configuration)\$(Platform)\</OutputPath>
1919
</PropertyGroup>
20-
20+
2121
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition=" Exists('$(MSBuildToolsPath)\Microsoft.Common.targets') " />
2222

2323
<PropertyGroup>
@@ -47,6 +47,10 @@
4747
Build
4848
</TestDependsOn>
4949

50+
<VSTestDependsOn>
51+
Build
52+
</VSTestDependsOn>
53+
5054
<CleanDependsOn>
5155
BeforeClean;
5256
UnmanagedUnregistration;
@@ -59,6 +63,10 @@
5963
<PackDependsOn>
6064
ResolveReferences;
6165
</PackDependsOn>
66+
67+
<PublishDependsOn>
68+
Build;
69+
</PublishDependsOn>
6270
</PropertyGroup>
6371

6472
<ItemGroup Condition=" '$(TraversalTranslateProjectFileItems)' != 'false' ">
@@ -209,6 +217,49 @@
209217
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
210218
</Target>
211219

220+
<Target Name="VSTest"
221+
DependsOnTargets="$(VSTestDependsOn)">
222+
223+
<MSBuild Projects="@(PreTraversalProject)"
224+
Targets="VSTest"
225+
Properties="$(PreTraversalGlobalProperties)"
226+
Condition=" '@(PreTraversalProject)' != '' "
227+
BuildInParallel="$(BuildInParallel)"
228+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
229+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
230+
231+
<MSBuild Projects="@(PreTraversalVSTestProject)"
232+
Targets="VSTest"
233+
Properties="$(PreTraversalVSTestGlobalProperties)"
234+
Condition=" '@(PreTraversalVSTestProject)' != '' "
235+
BuildInParallel="$(BuildInParallel)"
236+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
237+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
238+
239+
<MSBuild Projects="@(_MSBuildProjectReferenceExistent)"
240+
Targets="VSTest"
241+
Properties="$(TraversalGlobalProperties);$(TraversalVSTestGlobalProperties)"
242+
BuildInParallel="$(BuildInParallel)"
243+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
244+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
245+
246+
<MSBuild Projects="@(PostTraversalVSTestProject)"
247+
Targets="VSTest"
248+
Properties="$(PostTraversalVSTestGlobalProperties)"
249+
Condition=" '@(PostTraversalVSTestProject)' != '' "
250+
BuildInParallel="$(BuildInParallel)"
251+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
252+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
253+
254+
<MSBuild Projects="@(PostTraversalProject)"
255+
Targets="VSTest"
256+
Properties="$(PostTraversalGlobalProperties)"
257+
Condition=" '@(PostTraversalProject)' != '' "
258+
BuildInParallel="$(BuildInParallel)"
259+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
260+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
261+
</Target>
262+
212263
<Target Name="Pack"
213264
DependsOnTargets="$(PackDependsOn)">
214265

@@ -251,7 +302,50 @@
251302
SkipNonexistentProjects="$(SkipNonexistentProjects)"
252303
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
253304
</Target>
254-
305+
306+
<Target Name="Publish"
307+
DependsOnTargets="$(PublishDependsOn)">
308+
309+
<MSBuild Projects="@(PreTraversalProject)"
310+
Targets="Publish"
311+
Properties="$(PreTraversalGlobalProperties)"
312+
Condition=" '@(PreTraversalProject)' != '' "
313+
BuildInParallel="$(BuildInParallel)"
314+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
315+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
316+
317+
<MSBuild Projects="@(PreTraversalPublishProject)"
318+
Targets="Publish"
319+
Properties="$(PreTraversalPublishGlobalProperties)"
320+
Condition=" '@(PreTraversalPublishProject)' != '' "
321+
BuildInParallel="$(BuildInParallel)"
322+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
323+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
324+
325+
<MSBuild Projects="@(_MSBuildProjectReferenceExistent)"
326+
Targets="Publish"
327+
Properties="$(TraversalGlobalProperties);$(TraversalPublishGlobalProperties)"
328+
BuildInParallel="$(BuildInParallel)"
329+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
330+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
331+
332+
<MSBuild Projects="@(PostTraversalPublishProject)"
333+
Targets="Publish"
334+
Properties="$(PostTraversalPublishGlobalProperties)"
335+
Condition=" '@(PostTraversalPublishProject)' != '' "
336+
BuildInParallel="$(BuildInParallel)"
337+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
338+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
339+
340+
<MSBuild Projects="@(PostTraversalProject)"
341+
Targets="Publish"
342+
Properties="$(PostTraversalGlobalProperties)"
343+
Condition=" '@(PostTraversalProject)' != '' "
344+
BuildInParallel="$(BuildInParallel)"
345+
SkipNonexistentProjects="$(SkipNonexistentProjects)"
346+
SkipNonexistentTargets="$(SkipNonexistentTargets)" />
347+
</Target>
348+
255349
<!--
256350
Traversal projects do not build anything and should not check for invalid configuration/platform.
257351
-->

0 commit comments

Comments
 (0)