I have a solution which builds in vs. When I load it with roslyn like so:
var workspace = MSBuildWorkspace.Create();
var solutionPath = @"c:\path\to\my.sln";
var solution = workspace.OpenSolutionAsync(solutionPath).Result;
then all of the projects have 0 metadata references.
If I try and get a type from a referenced assembly like this:
var compilation = solution.Projects.First().GetCompilationAsync().Result;
var myType = compilation.GetTypeByMetadataName("SomeTypeNanme);
it never finds the type. If I manually add metadata references like this:
var project = project.AddMetadataReference(AssemblyContaningTheType);
Then it can find the type.
My solution targets .NET Framework 4.5.2, in case that matters
Is this the only way to resolve the references, ie adding the metadata references manually? Can it not be done through the fact that the references are all in the csproj? How can I know what all the references that I need to add?
Ideally I'd like to have references resolved automatically, but would be ok with pointers on building all neccessary metadata references from the info in the project files...