@@ -62,37 +62,19 @@ public static BuildOptions GetBuildOptions(ParseResult parseResult, int degreeOf
6262 parseResult . GetValue ( TestingPlatformOptions . SolutionOption ) ,
6363 parseResult . GetValue ( TestingPlatformOptions . DirectoryOption ) ) ;
6464
65- BuildProperties buildProperties = new (
66- parseResult . GetValue ( TestingPlatformOptions . ConfigurationOption ) ,
67- ResolveRuntimeIdentifier ( parseResult ) ,
68- parseResult . GetValue ( TestingPlatformOptions . FrameworkOption ) ) ;
69-
7065 return new BuildOptions (
7166 pathOptions ,
72- buildProperties ,
7367 parseResult . GetValue ( CommonOptions . NoRestoreOption ) ,
7468 parseResult . GetValue ( TestingPlatformOptions . NoBuildOption ) ,
7569 parseResult . HasOption ( CommonOptions . VerbosityOption ) ? parseResult . GetValue ( CommonOptions . VerbosityOption ) : null ,
7670 degreeOfParallelism ,
77- parseResult . GetValue ( CommonOptions . PropertiesOption ) ,
71+ GetGlobalProperties ( [ .. msbuildArgs ] ) ,
7872 unmatchedTokens ,
7973 msbuildArgs ) ;
8074 }
8175
82- private static string ResolveRuntimeIdentifier ( ParseResult parseResult )
83- {
84- if ( parseResult . HasOption ( CommonOptions . RuntimeOption ) )
85- {
86- return parseResult . GetValue ( CommonOptions . RuntimeOption ) ;
87- }
88-
89- if ( ! parseResult . HasOption ( CommonOptions . OperatingSystemOption ) && ! parseResult . HasOption ( CommonOptions . ArchitectureOption ) )
90- {
91- return string . Empty ;
92- }
93-
94- return CommonOptions . ResolveRidShorthandOptionsToRuntimeIdentifier ( parseResult . GetValue ( CommonOptions . OperatingSystemOption ) , parseResult . GetValue ( CommonOptions . ArchitectureOption ) ) ;
95- }
76+ private static string [ ] ? GetGlobalProperties ( IReadOnlyList < string > args )
77+ => new CliConfiguration ( new CliCommand ( "dotnet" ) { CommonOptions . PropertiesOption } ) . Parse ( args ) . GetValue ( CommonOptions . PropertiesOption ) ;
9678
9779 private static IEnumerable < string > GetBinaryLoggerTokens ( IEnumerable < string > args )
9880 {
@@ -140,39 +122,16 @@ private static ConcurrentBag<TestModule> GetProjectsProperties(ProjectCollection
140122
141123 private static Dictionary < string , string > GetGlobalProperties ( BuildOptions buildOptions )
142124 {
143- var globalProperties = new Dictionary < string , string > ( ) ;
144- var buildProperties = buildOptions . BuildProperties ;
125+ var globalProperties = new Dictionary < string , string > ( buildOptions . UserSpecifiedProperties . Length ) ;
145126
146127 foreach ( var property in buildOptions . UserSpecifiedProperties )
147128 {
148129 foreach ( var ( key , value ) in MSBuildPropertyParser . ParseProperties ( property ) )
149130 {
150- if ( globalProperties . TryGetValue ( key , out var existingValues ) )
151- {
152- globalProperties [ key ] = $ "{ existingValues } ;{ value } ";
153- }
154- else
155- {
156- globalProperties [ key ] = value ;
157- }
131+ globalProperties [ key ] = value ;
158132 }
159133 }
160134
161- if ( ! string . IsNullOrEmpty ( buildProperties . Configuration ) )
162- {
163- globalProperties [ CliConstants . Configuration ] = buildProperties . Configuration ;
164- }
165-
166- if ( ! string . IsNullOrEmpty ( buildProperties . RuntimeIdentifier ) )
167- {
168- globalProperties [ CliConstants . RuntimeIdentifier ] = buildProperties . RuntimeIdentifier ;
169- }
170-
171- if ( ! string . IsNullOrEmpty ( buildProperties . TargetFramework ) )
172- {
173- globalProperties [ CliConstants . TargetFramework ] = buildProperties . TargetFramework ;
174- }
175-
176135 return globalProperties ;
177136 }
178137}
0 commit comments