问题
I try Emit each project in this solution.
I wonder why there is a problem with Emiting "Wpf" and "Silverlight" projects. I can understand that I can't Emit Console Project that I am currently executing.
How I can add missing references? Here is my code.:
public static async Task EmitProject(Project proj)
{
var c = await proj.GetCompilationAsync();
var r = c.Emit("my" + proj.Name );
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(r.Success + " " + proj.Name);
if (!r.Success)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(r.Diagnostics.First(k => k.WarningLevel == 0));
}
}
回答1:
Silverlight and WPF projects have a somewhat complicated build process, where some of the code is generated at build time by things like the XAML Markup Compiler. Calling Emit
doesn't trigger that code to run - it just represents a single call to the CSC task in MSBuild.
Most of the time OpenSolutionAsync
actually causes the build to progress far enough that the invocation of CSC will work, but apparently not for these project types.
For the ConsoleApplication, the issue is that it references a PCL, and the facade references are not being added correctly.
Can you file an issue at http://github.com/dotnet/roslyn for us to investigate?
来源:https://stackoverflow.com/questions/27997630/roslyn-workspace-api-emiting-wpf-and-silverlight-projects