Open svick opened 8 years ago
Assigning to IDE as MSBuildWorkspace
is in the workspaces layer.
@svick Is this something you're still working around by chance?
I don't need this code anymore, I don't even remember why I did when I opened this issue.
But I have now updated the code to:
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Build.Locator;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.MSBuild;
using static Microsoft.CodeAnalysis.DiagnosticSeverity;
static class Program
{
private const string SolutionPath = @"C:\code\corefx\src\System.Diagnostics.Debug\System.Diagnostics.Debug.sln";
static async Task Main()
{
MSBuildLocator.RegisterDefaults();
var workspace = MSBuildWorkspace.Create();
var solution = await workspace.OpenSolutionAsync(SolutionPath);
foreach (var project in solution.Projects)
{
var compilation = await project.GetCompilationAsync();
//compilation = compilation.WithOptions(compilation.Options.WithOutputKind(OutputKind.DynamicallyLinkedLibrary));
if (compilation.GetDiagnostics().Any(d => d.Severity == Error))
{
foreach (var diagnostic in compilation.GetDiagnostics())
{
Console.WriteLine($"{project.Name}: {diagnostic}");
}
}
}
}
}
I then ran it with current versions of Roslyn and corefx and the output was:
System.Diagnostics.Debug.Tests: error CS5001: Program does not contain a static 'Main' method suitable for an entry point
System.Diagnostics.Debug: error CS5001: Program does not contain a static 'Main' method suitable for an entry point
System.Diagnostics.Debug: error CS5001: Program does not contain a static 'Main' method suitable for an entry point
You can fairly easily work around those errors (see commented-out line in the above code), but I think it does imply something is still wrong.
If you think that's not worth investigating, feel free to close this issue.
I'm trying to compile corefx using
MSBuildWorkspace
and I'm failing at System.Diagnostics.Debug.The errors I'm getting are all of the form:
Where X are various basic types like
Object
,Enum
,Attribute
orIEnumerable<>
(full error list).Since running msbuild from the command line works fine (it only warns that "Packages containing MSBuild targets and props files cannot be fully installed in projects targeting multiple frameworks.", which I think is not relevant), I'm assuming this is an issue in Roslyn and not in the corefx project.
Running msbuild previously also should have restored all necessary packages and
project.MetadataReferences
looks okay to me (it contains 23 items, including Microsoft.TargetingPack.Private.CoreCLR\1.0.0-rc3-23910\lib\netstandard1.0\mscorlib.dll).I'm using packages version 1.3.0-beta1-20160304-02 from Roslyn nightly MyGet. My code: