@@ -17,13 +17,21 @@ public void BuildMultiProject(string config, string projectName)
1717 Assert . IsTrue ( DotnetInternal . New ( "maui-multiproject" , projectDir , DotNetCurrent ) ,
1818 $ "Unable to create template maui-multiproject. Check test output for errors.") ;
1919
20- if ( ! TestEnvironment . IsWindows )
20+ // Always remove WinUI project if the project name contains special characters that cause WinRT source generator issues
21+ // See: https://github.com/microsoft/CsWinRT/issues/1809 (under "Special characters in assembly name" section)
22+ bool containsSpecialChars = projectName . IndexOfAny ( new [ ] { '@' , '&' , '+' , '%' , '!' , '#' , '$' , '^' , '*' , ' ' , '-' } ) >= 0 ;
23+
24+ if ( ! TestEnvironment . IsWindows || containsSpecialChars )
2125 {
2226 Assert . IsTrue ( DotnetInternal . Run ( "sln" , $ "\" { solutionFile } \" remove \" { projectDir } /{ name } .WinUI/{ name } .WinUI.csproj\" ") ,
2327 $ "Unable to remove WinUI project from solution. Check test output for errors.") ;
2428 }
2529
26- Assert . IsTrue ( DotnetInternal . Build ( solutionFile , config , properties : BuildProps , msbuildWarningsAsErrors : true ) ,
30+ // TODO, we should not need this but hitting: https://github.com/dotnet/maui/issues/19840
31+ var buildProps = BuildProps ;
32+ buildProps . Add ( "ResizetizerErrorOnDuplicateOutputFilename=false" ) ;
33+
34+ Assert . IsTrue ( DotnetInternal . Build ( solutionFile , config , properties : buildProps , msbuildWarningsAsErrors : true ) ,
2735 $ "Solution { name } failed to build. Check test output/attachments for errors.") ;
2836 }
2937
@@ -50,4 +58,63 @@ public void BuildMultiProjectSinglePlatform(string config, string platformArg)
5058 Assert . IsTrue ( DotnetInternal . Build ( solutionFile , config , properties : BuildProps , msbuildWarningsAsErrors : true ) ,
5159 $ "Solution { name } failed to build. Check test output/attachments for errors.") ;
5260 }
61+
62+ [ Test ]
63+ [ TestCase ( "--android" ) ]
64+ [ TestCase ( "--ios" ) ]
65+ [ TestCase ( "--windows" ) ]
66+ [ TestCase ( "--macos" ) ]
67+ [ TestCase ( "" ) ] // no platform arg means all platforms
68+ // https://github.com/dotnet/maui/issues/28695
69+ public void VerifyIncludedPlatformsInSln ( string platformArg )
70+ {
71+ var projectDir = TestDirectory ;
72+ var name = Path . GetFileName ( projectDir ) ;
73+ var solutionFile = Path . Combine ( projectDir , $ "{ name } .sln") ;
74+
75+ Assert . IsTrue ( DotnetInternal . New ( $ "maui-multiproject { platformArg } ", projectDir , DotNetCurrent ) ,
76+ $ "Unable to create template maui-multiproject. Check test output for errors.") ;
77+
78+ var slnListOutput = DotnetInternal . RunForOutput ( "sln" , $ "{ solutionFile } list", out int exitCode ) ;
79+
80+ // Asserts the process completed successfully
81+ Assert . AreEqual ( 0 , exitCode , $ "Unable to list projects in solution. Check test output for errors.") ;
82+
83+ // Asserts if the shared project is included in the solution, this should always be the case
84+ Assert . IsTrue ( slnListOutput . Contains ( $ "{ name } .csproj", StringComparison . OrdinalIgnoreCase ) ,
85+ $ "Expected shared project (with name { name } .csproj) to be included in the solution.") ;
86+
87+ var expectedCsprojFiles = new List < string > { "Droid.csproj" , "iOS.csproj" , "Mac.csproj" , "WinUI.csproj" } ;
88+
89+ switch ( platformArg )
90+ {
91+ case "--android" :
92+ expectedCsprojFiles . Remove ( "iOS.csproj" ) ;
93+ expectedCsprojFiles . Remove ( "WinUI.csproj" ) ;
94+ expectedCsprojFiles . Remove ( "Mac.csproj" ) ;
95+ break ;
96+ case "--ios" :
97+ expectedCsprojFiles . Remove ( "Droid.csproj" ) ;
98+ expectedCsprojFiles . Remove ( "WinUI.csproj" ) ;
99+ expectedCsprojFiles . Remove ( "Mac.csproj" ) ;
100+ break ;
101+ case "--windows" :
102+ expectedCsprojFiles . Remove ( "Droid.csproj" ) ;
103+ expectedCsprojFiles . Remove ( "iOS.csproj" ) ;
104+ expectedCsprojFiles . Remove ( "Mac.csproj" ) ;
105+ break ;
106+ case "--macos" :
107+ expectedCsprojFiles . Remove ( "Droid.csproj" ) ;
108+ expectedCsprojFiles . Remove ( "iOS.csproj" ) ;
109+ expectedCsprojFiles . Remove ( "WinUI.csproj" ) ;
110+ break ;
111+ }
112+
113+ // Depending on the platform argument, we assert if the expected projects are included in the solution
114+ foreach ( var platformCsproj in expectedCsprojFiles )
115+ {
116+ Assert . IsTrue ( slnListOutput . Contains ( platformCsproj , StringComparison . Ordinal ) ,
117+ $ "Expected { platformCsproj } to be included in the solution.") ;
118+ }
119+ }
53120}
0 commit comments