@@ -105,85 +105,39 @@ public static IEnumerable<TestModule> GetProjectProperties(string projectFilePat
105
105
{
106
106
var projects = new List < TestModule > ( ) ;
107
107
108
- var globalPropertiesWithoutTargetFramework = new Dictionary < string , string > ( globalProperties ) ;
109
- globalPropertiesWithoutTargetFramework . Remove ( ProjectProperties . TargetFramework ) ;
110
108
111
- var project = projectCollection . LoadProject ( projectFilePath , globalPropertiesWithoutTargetFramework , null ) ;
109
+ var project = projectCollection . LoadProject ( projectFilePath , globalProperties , null ) ;
112
110
113
- // Check if TargetFramework is specified in global properties
114
- if ( globalProperties . TryGetValue ( ProjectProperties . TargetFramework , out string targetFramework ) )
115
- {
116
- Logger . LogTrace ( ( ) => $ "Loaded project '{ Path . GetFileName ( projectFilePath ) } ' with global property TargetFramework '{ targetFramework } '.") ;
117
-
118
- if ( IsValidTargetFramework ( project , targetFramework ) )
119
- {
120
- Logger . LogTrace ( ( ) => $ "Project '{ Path . GetFileName ( projectFilePath ) } ' with TargetFramework '{ targetFramework } ': before re-evaluation '{ ProjectProperties . IsTestingPlatformApplication } ' is '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } '.") ;
111
+ var targetFramework = project . GetPropertyValue ( ProjectProperties . TargetFramework ) ;
112
+ var targetFrameworks = project . GetPropertyValue ( ProjectProperties . TargetFrameworks ) ;
113
+ Logger . LogTrace ( ( ) => $ "Loaded project '{ Path . GetFileName ( projectFilePath ) } ' with TargetFramework '{ targetFramework } ', TargetFrameworks '{ targetFrameworks } ', IsTestProject '{ project . GetPropertyValue ( ProjectProperties . IsTestProject ) } ', and '{ ProjectProperties . IsTestingPlatformApplication } ' is '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } '.") ;
121
114
122
- project . SetProperty ( ProjectProperties . TargetFramework , targetFramework ) ;
123
- project . ReevaluateIfNecessary ( ) ;
124
-
125
- Logger . LogTrace ( ( ) => $ "Project '{ Path . GetFileName ( projectFilePath ) } ' with TargetFramework '{ targetFramework } ': after re-evaluation '{ ProjectProperties . IsTestingPlatformApplication } ' is '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } '.") ;
126
-
127
- if ( GetModuleFromProject ( project ) is { } module )
128
- {
129
- projects . Add ( module ) ;
130
- }
131
- }
132
- else
115
+ if ( ! string . IsNullOrEmpty ( targetFramework ) || string . IsNullOrEmpty ( targetFrameworks ) )
116
+ {
117
+ if ( GetModuleFromProject ( project ) is { } module )
133
118
{
134
- // TODO: When can this happen? Should we explicitly error?
135
- Logger . LogTrace ( ( ) => $ "Project '{ Path . GetFileName ( projectFilePath ) } ' with TargetFramework '{ targetFramework } ' was considered invalid.") ;
119
+ projects . Add ( module ) ;
136
120
}
137
121
}
138
122
else
139
123
{
140
- string targetFrameworks = project . GetPropertyValue ( ProjectProperties . TargetFrameworks ) ;
141
-
142
- if ( string . IsNullOrEmpty ( targetFrameworks ) )
124
+ var frameworks = targetFrameworks . Split ( CliConstants . SemiColon , StringSplitOptions . RemoveEmptyEntries ) ;
125
+ foreach ( var framework in frameworks )
143
126
{
144
- Logger . LogTrace ( ( ) => $ "Loaded project '{ Path . GetFileName ( projectFilePath ) } ' has '{ ProjectProperties . IsTestingPlatformApplication } ' = '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } '.") ;
127
+ project . SetProperty ( ProjectProperties . TargetFramework , framework ) ;
128
+ project . ReevaluateIfNecessary ( ) ;
129
+ Logger . LogTrace ( ( ) => $ "Loaded inner project '{ Path . GetFileName ( projectFilePath ) } ' has '{ ProjectProperties . IsTestingPlatformApplication } ' = '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } ' (TFM: '{ framework } ').") ;
145
130
146
131
if ( GetModuleFromProject ( project ) is { } module )
147
132
{
148
133
projects . Add ( module ) ;
149
134
}
150
135
}
151
- else
152
- {
153
- Logger . LogTrace ( ( ) => $ "Loaded project '{ Path . GetFileName ( projectFilePath ) } ' has '{ ProjectProperties . IsTestingPlatformApplication } ' = '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } ' (TFMs: '{ targetFrameworks } ').") ;
154
-
155
- var frameworks = targetFrameworks . Split ( CliConstants . SemiColon , StringSplitOptions . RemoveEmptyEntries ) ;
156
- foreach ( var framework in frameworks )
157
- {
158
- project . SetProperty ( ProjectProperties . TargetFramework , framework ) ;
159
- project . ReevaluateIfNecessary ( ) ;
160
-
161
- Logger . LogTrace ( ( ) => $ "Loaded project '{ Path . GetFileName ( projectFilePath ) } ' has '{ ProjectProperties . IsTestingPlatformApplication } ' = '{ project . GetPropertyValue ( ProjectProperties . IsTestingPlatformApplication ) } ' (TFM: '{ framework } ').") ;
162
-
163
- if ( GetModuleFromProject ( project ) is { } module )
164
- {
165
- projects . Add ( module ) ;
166
- }
167
- }
168
- }
169
136
}
170
137
171
138
return projects ;
172
139
}
173
140
174
-
175
- private static bool IsValidTargetFramework ( Project project , string targetFramework )
176
- {
177
- string targetFrameworks = project . GetPropertyValue ( ProjectProperties . TargetFrameworks ) ;
178
- if ( string . IsNullOrEmpty ( targetFrameworks ) )
179
- {
180
- return project . GetPropertyValue ( ProjectProperties . TargetFramework ) == targetFramework ;
181
- }
182
-
183
- var frameworks = targetFrameworks . Split ( CliConstants . SemiColon , StringSplitOptions . RemoveEmptyEntries ) ;
184
- return frameworks . Contains ( targetFramework ) ;
185
- }
186
-
187
141
private static TestModule ? GetModuleFromProject ( Project project )
188
142
{
189
143
_ = bool . TryParse ( project . GetPropertyValue ( ProjectProperties . IsTestProject ) , out bool isTestProject ) ;
0 commit comments