Skip to content

Commit

Permalink
Log WorkspaceFail events (#1738)
Browse files Browse the repository at this point in the history
MSBuildWorkspace.OpenSolutionAsync() and MSBuildWorkspace.OpenProjectAsync() do not give any notification that loading a solution or project failed. However, there is a WorkspaceFailed event that we can use to be notified when there is a problem. This logs the diagnotic information from this event to help the user troubleshoot.

Related:
* dotnet/roslyn#19978 (comment)
* #1686
* #1708 (comment)
  • Loading branch information
dlech authored and vicancy committed Jun 15, 2017
1 parent 8b02b0f commit a16485b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ public ExtractMetadataWorker(ExtractMetadataInputModel input, bool rebuild, bool
_msbuildProperties["Configuration"] = "Release";
}

_workspace = new Lazy<MSBuildWorkspace>(() => MSBuildWorkspace.Create(_msbuildProperties));
_workspace = new Lazy<MSBuildWorkspace>(() =>
{
var workspace = MSBuildWorkspace.Create(_msbuildProperties);
workspace.WorkspaceFailed += (s, e) =>
{
Logger.LogWarning($"Workspace failed with: {e.Diagnostic}");
};
return workspace;
});
}

public async Task ExtractMetadataAsync()
Expand Down

0 comments on commit a16485b

Please sign in to comment.