Skip to content

Fix AnalyzerRunner failure to load Microsoft.Build.Framework#43101

Merged
sharwell merged 1 commit intodotnet:release/dev16.6from
sharwell:fix-analyzer-runner
Apr 14, 2020
Merged

Fix AnalyzerRunner failure to load Microsoft.Build.Framework#43101
sharwell merged 1 commit intodotnet:release/dev16.6from
sharwell:fix-analyzer-runner

Conversation

@sharwell
Copy link
Contributor

@sharwell sharwell commented Apr 6, 2020

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at AnalyzerRunner.Program.Main(String[] args)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at AnalyzerRunner.Program.Main(String[] args)
   at AnalyzerRunner.Program.<Main>(String[] args)

@sharwell sharwell requested a review from a team as a code owner April 6, 2020 06:16
Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the commit message explaining the problem and how this is fixing it, since that's not obvious at all here.

@sharwell
Copy link
Contributor Author

sharwell commented Apr 7, 2020

@jasonmalinowski I do not know how/why this fixes the problem. After getting loader exceptions, I copied the approach from dotnet/format, and when it worked I sent this pull request.

https://github.com/dotnet/format/blob/d6a90a3013f5ace4efd42525b0b0400c7ced610e/src/dotnet-format.csproj#L29-L30

@JoeRobich
Copy link
Member

JoeRobich commented Apr 7, 2020

The changes to support producing a binary log from MSBuildWorkspace use the ILogger interface.

/// <summary>
/// Open a solution file and all referenced projects.
/// </summary>
/// <param name="solutionFilePath">The path to the solution file to be opened. This may be an absolute path or a path relative to the
/// current working directory.</param>
/// <param name="progress">An optional <see cref="IProgress{T}"/> that will receive updates as the solution is opened.</param>
/// <param name="msbuildLogger">An optional <see cref="ILogger"/> that will log msbuild results.</param>
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> to allow cancellation of this operation.</param>
public async Task<Solution> OpenSolutionAsync(
string solutionFilePath,
IProgress<ProjectLoadProgress> progress = null,
ILogger msbuildLogger = null,
CancellationToken cancellationToken = default)
{
if (solutionFilePath == null)
{
throw new ArgumentNullException(nameof(solutionFilePath));
}
this.ClearSolution();
var solutionInfo = await _loader.LoadSolutionInfoAsync(solutionFilePath, progress, msbuildLogger, cancellationToken).ConfigureAwait(false);
// construct workspace from loaded project infos
this.OnSolutionAdded(solutionInfo);
this.UpdateReferencesAfterAdd();
return this.CurrentSolution;
}

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we understand why this fixes it though?

@sharwell
Copy link
Contributor Author

Do we understand why this fixes it though?

Not currently. The MSBuildLocator is still magic to me.

@sharwell sharwell merged commit 52ce42e into dotnet:release/dev16.6 Apr 14, 2020
@sharwell sharwell deleted the fix-analyzer-runner branch April 14, 2020 14:07
@sharwell
Copy link
Contributor Author

Merging to 16.6 as non-production code only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants