22//
33// Licensed under the MIT license.
44
5+ using Microsoft . Build . Evaluation ;
56using Microsoft . Build . Framework ;
67using Microsoft . Build . Utilities . ProjectCreation ;
78using Shouldly ;
9+ using System ;
10+ using System . Collections . Generic ;
811using System . Linq ;
912using UnitTest . Common ;
1013using Xunit ;
@@ -13,7 +16,7 @@ namespace Microsoft.Build.Traversal.UnitTests
1316{
1417 public class TraversalTests : MSBuildSdkTestBase
1518 {
16- [ Fact ( Skip = "This does not currently work, need to investigate why" ) ]
19+ [ Fact ]
1720 public void SkipsNonExistentTargets ( )
1821 {
1922 string [ ] projects = new [ ]
@@ -35,17 +38,16 @@ public void SkipsNonExistentTargets()
3538 }
3639
3740 [ Theory ]
41+ [ InlineData ( "Clean" ) ]
3842 [ InlineData ( "Build" ) ]
3943 [ InlineData ( "Test" ) ]
4044 public void TraversalTargetsRun ( string target )
4145 {
4246 string [ ] projects = new [ ]
4347 {
4448 ProjectCreator . Templates . LogsMessage ( "BF0C6E1044514FE3AE4B78EC308D6F45" , MessageImportance . High , targetName : target , path : GetTempFileWithExtension ( ".proj" ) )
45- . Target ( "GetNativeManifest" )
4649 . Save ( ) ,
4750 ProjectCreator . Templates . LogsMessage ( "40869F4000B44D75A52AB305F24E0FDB" , MessageImportance . High , targetName : target , path : GetTempFileWithExtension ( ".proj" ) )
48- . Target ( "GetNativeManifest" )
4951 . Save ( ) ,
5052 } . Select ( i => i . FullPath ) . ToArray ( ) ;
5153
@@ -72,5 +74,40 @@ public void TraversalTargetsRun(string target)
7274 ignoreOrder : true ,
7375 customMessage : ( ) => buildOutput . GetConsoleLog ( ) ) ;
7476 }
77+
78+ [ Theory ]
79+ [ InlineData ( null ) ]
80+ [ InlineData ( "Debug" ) ]
81+ [ InlineData ( "Release" ) ]
82+ [ InlineData ( "Random" ) ]
83+ public void WorksWhenConfigurationSpecified ( string configuration )
84+ {
85+ Dictionary < string , string > globalProperties = new Dictionary < string , string >
86+ {
87+ [ "DesignTimeBuild" ] = "true"
88+ } ;
89+
90+ if ( ! String . IsNullOrWhiteSpace ( configuration ) )
91+ {
92+ globalProperties . Add ( "Configuration" , configuration ) ;
93+ }
94+
95+ string [ ] projects = new [ ]
96+ {
97+ ProjectCreator . Templates . SdkCsproj ( path : GetTempFileWithExtension ( ".csproj" ) )
98+ . Save ( ) ,
99+ } . Select ( i => i . FullPath ) . ToArray ( ) ;
100+
101+ ProjectCreator
102+ . Templates
103+ . TraversalProject (
104+ projects ,
105+ path : GetTempFile ( "dirs.proj" ) ,
106+ projectCollection : new ProjectCollection ( globalProperties ) )
107+ . Save ( )
108+ . TryBuild ( "Clean" , out bool result , out BuildOutput buildOutput ) ;
109+
110+ result . ShouldBeTrue ( customMessage : ( ) => buildOutput . GetConsoleLog ( ) ) ;
111+ }
75112 }
76113}
0 commit comments