@@ -34,14 +34,13 @@ int IVsSolutionLoadEvents.OnBeforeOpenSolution(string pszSolutionFilename)
34
34
}
35
35
36
36
private async Task LoadSolutionFromMSBuildAsync (
37
- IDeferredProjectWorkspaceService deferredProjectWorkspaceService ,
38
37
CancellationToken cancellationToken )
39
38
{
40
39
AssertIsForeground ( ) ;
41
40
InitializeOutputPane ( ) ;
42
41
43
42
// Continue on the UI thread for these operations, since we are touching the VisualStudioWorkspace, etc.
44
- await PopulateWorkspaceFromDeferredProjectInfoAsync ( deferredProjectWorkspaceService , cancellationToken ) . ConfigureAwait ( true ) ;
43
+ await PopulateWorkspaceFromDeferredProjectInfoAsync ( cancellationToken ) . ConfigureAwait ( true ) ;
45
44
}
46
45
47
46
[ Conditional ( "DEBUG" ) ]
@@ -104,7 +103,6 @@ int IVsSolutionLoadEvents.OnAfterBackgroundSolutionLoadComplete()
104
103
}
105
104
106
105
private async Task PopulateWorkspaceFromDeferredProjectInfoAsync (
107
- IDeferredProjectWorkspaceService deferredProjectWorkspaceService ,
108
106
CancellationToken cancellationToken )
109
107
{
110
108
// NOTE: We need to check cancellationToken after each await, in case the user has
@@ -127,6 +125,7 @@ private async Task PopulateWorkspaceFromDeferredProjectInfoAsync(
127
125
if ( solutionConfig != null )
128
126
{
129
127
// Capture the context so that we come back on the UI thread, and do the actual project creation there.
128
+ var deferredProjectWorkspaceService = _workspaceServices . GetService < IDeferredProjectWorkspaceService > ( ) ;
130
129
projectInfos = await deferredProjectWorkspaceService . GetDeferredProjectInfoForConfigurationAsync (
131
130
$ "{ solutionConfig . Name } |{ solutionConfig . PlatformName } ",
132
131
cancellationToken ) . ConfigureAwait ( true ) ;
@@ -139,11 +138,13 @@ private async Task PopulateWorkspaceFromDeferredProjectInfoAsync(
139
138
OutputToOutputWindow ( $ "Creating projects - start") ;
140
139
start = DateTimeOffset . UtcNow ;
141
140
var targetPathsToProjectPaths = BuildTargetPathMap ( projectInfos ) ;
141
+ var analyzerAssemblyLoader = _workspaceServices . GetRequiredService < IAnalyzerService > ( ) . GetLoader ( ) ;
142
142
foreach ( var projectFilename in projectInfos . Keys )
143
143
{
144
144
cancellationToken . ThrowIfCancellationRequested ( ) ;
145
145
GetOrCreateProjectFromArgumentsAndReferences (
146
146
workspaceProjectContextFactory ,
147
+ analyzerAssemblyLoader ,
147
148
projectFilename ,
148
149
projectInfos ,
149
150
targetPathsToProjectPaths ) ;
@@ -185,6 +186,7 @@ private void OutputToOutputWindow(string message)
185
186
186
187
private AbstractProject GetOrCreateProjectFromArgumentsAndReferences (
187
188
IWorkspaceProjectContextFactory workspaceProjectContextFactory ,
189
+ IAnalyzerAssemblyLoader analyzerAssemblyLoader ,
188
190
string projectFilename ,
189
191
IReadOnlyDictionary < string , DeferredProjectInformation > allProjectInfos ,
190
192
IReadOnlyDictionary < string , string > targetPathsToProjectPaths )
@@ -263,6 +265,7 @@ private AbstractProject GetOrCreateProjectFromArgumentsAndReferences(
263
265
hierarchy : null ,
264
266
binOutputPath : outputPath ) ;
265
267
268
+ project = ( AbstractProject ) projectContext ;
266
269
projectContext . SetOptions ( projectInfo . CommandLineArguments . Join ( " " ) ) ;
267
270
268
271
foreach ( var sourceFile in commandLineArguments . SourceFiles )
@@ -287,6 +290,7 @@ private AbstractProject GetOrCreateProjectFromArgumentsAndReferences(
287
290
{
288
291
referencedProject = GetOrCreateProjectFromArgumentsAndReferences (
289
292
workspaceProjectContextFactory ,
293
+ analyzerAssemblyLoader ,
290
294
projectReferencePath ,
291
295
allProjectInfos ,
292
296
targetPathsToProjectPaths ) ;
@@ -322,22 +326,30 @@ private AbstractProject GetOrCreateProjectFromArgumentsAndReferences(
322
326
}
323
327
}
324
328
325
- foreach ( var reference in commandLineArguments . MetadataReferences )
329
+ foreach ( var reference in commandLineArguments . ResolveMetadataReferences ( project . CurrentCompilationOptions . MetadataReferenceResolver ) )
326
330
{
331
+ // Some references may fail to be resolved - if they are, we'll still pass them
332
+ // through, in case they come into existence later (they may be built by other
333
+ // parts of the build system).
334
+ var unresolvedReference = reference as UnresolvedMetadataReference ;
335
+ var path = unresolvedReference == null
336
+ ? ( ( PortableExecutableReference ) reference ) . FilePath
337
+ : unresolvedReference . Reference ;
338
+
327
339
string possibleProjectReference ;
328
- if ( targetPathsToProjectPaths . TryGetValue ( reference . Reference , out possibleProjectReference ) &&
340
+ if ( targetPathsToProjectPaths . TryGetValue ( path , out possibleProjectReference ) &&
329
341
addedProjectReferences . Contains ( possibleProjectReference ) )
330
342
{
331
343
// We already added a P2P reference for this, we don't need to add the file reference too.
332
344
continue ;
333
345
}
334
346
335
- projectContext . AddMetadataReference ( reference . Reference , reference . Properties ) ;
347
+ projectContext . AddMetadataReference ( path , reference . Properties ) ;
336
348
}
337
349
338
- foreach ( var reference in commandLineArguments . AnalyzerReferences )
350
+ foreach ( var reference in commandLineArguments . ResolveAnalyzerReferences ( analyzerAssemblyLoader ) )
339
351
{
340
- var path = reference . FilePath ;
352
+ var path = reference . FullPath ;
341
353
if ( ! PathUtilities . IsAbsolute ( path ) )
342
354
{
343
355
path = PathUtilities . CombineAbsoluteAndRelativePaths (
0 commit comments