New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuildWorkspace fails to load metadatareferences for a project with a non-existent default configuration #5389

Open
mhgamework opened this Issue Sep 22, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@mhgamework
Copy link

mhgamework commented Sep 22, 2015

I loaded a csproj using MSBuildWorkspace but the project.MetadataReferences was empty. The project compiles and runs fine in VS2015 and has numerous (+15) third party references. I discovered that the project had the default configuration Debug|AnyCPU, which did not exists, so i fixed it to an existing configuration and the project now loads fine.

I do not understand this behaviour, it seems like a bug to me, or that there should be some sort of exception thrown.

For more information, see: http://stackoverflow.com/questions/32634648/compilation-fails-with-roslyn-but-works-with-visual-studio/32650912?noredirect=1#comment53249254_32650912

@Pilchie Pilchie added this to the 1.2 milestone Sep 22, 2015

@Pilchie

This comment has been minimized.

Copy link
Member

Pilchie commented Sep 22, 2015

Can you construct a repro project with this behavior?

@mhgamework

This comment has been minimized.

Copy link

mhgamework commented Sep 23, 2015

Yes, I can and have stored the solution in a zip archive. Is there a way I can upload this archive here? At the moment I have shared it on my dropbox.
https://www.dropbox.com/s/p8j3v3uqh6u1z52/RoslynIssue5389.zip?dl=0

@Pilchie

This comment has been minimized.

Copy link
Member

Pilchie commented Sep 24, 2015

Thanks! I've saved a copy of this inside Microsoft if you want to free up the space on your dropbox.

@leftler

This comment has been minimized.

Copy link

leftler commented Oct 24, 2016

I came to post a similar issue. If you would like another repo example see https://github.com/leftler/RoslynIssue

I did not realize I could just check project.MetadataReferences in my repo I did

    [TestMethod]
    public async Task TestFailingDummyProgramWithDefaultSettings()
    {
        var ws = Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create();
        var solution = await ws.OpenSolutionAsync(@"..\FailingProgram\DummyProgram.sln");
        Assert.AreEqual(1, solution.Projects.Count());

        foreach (var project in solution.Projects)
        {
            var comp = await project.GetCompilationAsync();
            Assert.IsTrue(comp.References.Any(x=>x.Display.EndsWith(@"\mscorlib.dll")), "Reference to mscorlib.dll not found found");
        }
    }

@Pilchie Pilchie modified the milestones: 3.0, 2.0 (RTM) Jan 19, 2017

@jasonmalinowski jasonmalinowski removed their assignment Jan 17, 2019

@jasonmalinowski jasonmalinowski modified the milestones: 16.0, Backlog Jan 17, 2019

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