Closed
Description
I'm trying to compile a WPF project using MSBuildWorkspace
. Should this work out of the box, or do I need to do anything special to set it up?
When I open a .sln containing a WPF project and try to compile I receive two errors:
C:\Users\Josh\Documents\GitHub\Orange\WpfApplication1\WpfApplication1\MainWindow.xaml.cs(25,13): error CS0103: The name 'InitializeComponent' does not exist in the current context
and
error CS5001: Program does not contain a static 'Main' method suitable for an entry point
To reproduce, simply create a new WPF project. (Mine was WPFApplication1.sln). Then just load into a workspace and try to compile the project.
var msws = MSBuildWorkspace.Create(new Dictionary<string, string> { { "CheckForSystemRuntimeDependency", "true" } });
var soln = msws.OpenSolutionAsync(@"C:\Users\Josh\Documents\GitHub\Orange\WpfApplication1\WpfApplication1.sln").Result;
var comp = soln.Projects.First().GetCompilationAsync().Result;
var errs = comp.GetDiagnostics().Where(n => n.Severity == DiagnosticSeverity.Error).ToList();
//Two errors :(