@@ -173,7 +173,7 @@ private string GetEffectiveBuildType(string? buildType)
173173 /// <param name="configuration">requested configuration</param>
174174 /// <param name="platform">requested platform</param>
175175 /// <returns></returns>
176- public ( string configuration , string platform ) GetProjectConfiguration ( string filename , string configuration , string platform )
176+ public ( string configuration , string platform ) GetProjectConfiguration ( string filename , string ? configuration , string ? platform )
177177 {
178178 configuration = GetEffectiveBuildType ( configuration ) ;
179179 platform ??= DefaultPlatform ;
@@ -189,30 +189,59 @@ private string GetEffectiveBuildType(string? buildType)
189189 /// </summary>
190190 /// <param name="projects">list of csproj filenames</param>
191191 /// <param name="platforms">list of declared platforms. Default to AnyCpu and x86</param>
192+ /// <param name="solutionPlatforms">list of solution level platforms</param>
192193 /// <returns>a solution instance</returns>
193194 /// <remarks>This method is used for testing purposes. It is mandatory as the underlying solution parser does not support any form of mocking</remarks>
194- public static SolutionFile BuildFromProjectList ( List < string > projects , string [ ] ? platforms = null )
195+ public static SolutionFile BuildFromProjectList ( List < string > projects , string [ ] ? platforms = null
196+ , string [ ] ? solutionPlatforms = null )
195197 {
196198 var result = new SolutionFile ( ) ;
199+ solutionPlatforms = DefineSolutionPlatforms ( platforms , solutionPlatforms ) ;
197200 platforms ??= [ "AnyCPU" , "x86" ] ;
201+ if ( platforms . Length != solutionPlatforms . Length )
202+ {
203+ throw new ArgumentException ( "The number of platforms should be the same as the number of solution platforms, if specified." ) ;
204+ }
198205 // default to Debug|Any CPU
199206 string [ ] buildTypes = [ "Debug" , "Release" ] ;
200207 foreach ( var buildType in buildTypes )
201208 {
202- foreach ( var platform in platforms )
209+ for ( var index = 0 ; index < platforms . Length ; index ++ )
203210 {
211+ var platform = platforms [ index ] ;
204212 var projectDict = new Dictionary < string , ( string buildType , string platform ) > ( ) ;
205213 foreach ( var project in projects )
206214 {
207215 projectDict [ project ] = ( buildType , platform ) ;
208216 }
209- var solutionPlatform = platform == "AnyCPU" ? "Any CPU" : platform ;
210- result . _configurations . Add ( ( buildType , solutionPlatform ) , projectDict ) ;
217+
218+ result . _configurations . Add ( ( buildType , solutionPlatforms [ index ] ) , projectDict ) ;
211219 }
212220 }
213221 return result ;
214222 }
215223
224+ private static string [ ] DefineSolutionPlatforms ( string [ ] ? platforms , string [ ] ? solutionPlatforms )
225+ {
226+ if ( solutionPlatforms == null )
227+ {
228+ if ( platforms == null )
229+ {
230+ solutionPlatforms = [ "Any CPU" , "x86" ] ;
231+ }
232+ else
233+ {
234+ solutionPlatforms = new string [ platforms . Length ] ;
235+ for ( var i = 0 ; i < platforms . Length ; i ++ )
236+ {
237+ solutionPlatforms [ i ] = platforms [ i ] == DefaultProjectBuildType ? DefaultSolutionType : platforms [ i ] ;
238+ }
239+ }
240+ }
241+
242+ return solutionPlatforms ;
243+ }
244+
216245 private static SolutionFile AnalyzeSolution ( string solutionPath , SolutionModel solution )
217246 {
218247 // extract needed information
0 commit comments