Roslyn Workspace API : Emiting Wpf and Silverlight Projects

不羁岁月 提交于 2019-12-11 07:54:54

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!