Replies: 2 comments
-
I would be intrested too,.. i could successfully emit an assembly out of a project which is .NET Core based and contains some XAML Files if I am passing "BuildingInsideVisualStudio". In this case, the ".g.cs" files are getting generated, but i am missing the resource files with the compiled (B)XAML content? In case I am removing the "BuildingInsideVisualStudio", i got the same exception as @ltcmelo using var workspace = MSBuildWorkspace.Create(new Dictionary<string, string>()
{
{ "BuildingInsideVisualStudio", "true" }
});
workspace.WorkspaceFailed += (o, e) => Console.WriteLine(e.Diagnostic.Message);
workspace.LoadMetadataForReferencedProjects = true;
var project = await workspace.OpenProjectAsync(sourceProject, new ConsoleLogger());
var compilation = await project.GetCompilationAsync();
var res = compilation.Emit("Test.exe"); |
Beta Was this translation helpful? Give feedback.
-
I'm using 3.7.0 and I've hit the same issue. I got passed that NRE, but ran into another error. This property helps (source): var workspace = MSBuildWorkspace.Create(new Dictionary<string, string> {
["AlwaysCompileMarkupFilesInSeparateDomain"] = "false"
}); The new error is:
Running the build task "manually" might help. Fortunately for me, I can just move my XAML files into a different project, because I don't actually have to compile them with the |
Beta Was this translation helpful? Give feedback.
-
Version Used: 3.6.0
I'm unable to correctly
OpenSolutionAsync
throughMSBuildWorkspace
when a project contains .xaml files. I get the following load failure:Which consequently leads to compilation errors like:
I've found this and this old issues (from 2015) that look the same as the one I'm facing. These, along with additional resources I've found online, suggest the setting the MSBuild properties
DesignTimeBuild
andBuildingInsideVisualStudio
totrue
(in the dictionary that's passed toMSBuildWorkspace.Create
would fix the issue. However, it seems that those properties are already set by default in the newerMSBuildWorkspace
versions (I'm using 3.6.0), so they didn't have any effect.Other things I've tried as well:
CheckForSystemRuntimeDependency
totrue
;ws.LoadMetadataForReferencedProjects
totrue
(wherews
is the workspace created).None of the above helped.
This is a snippet of how the
.csproj
includes the.xaml
content.An invocation of msbuild.exe from the command line successfully builds the project.
What's the recommendation to deal with this kind of artefacts in a project? (I'd accept a "unorthodox" way of compiling the hidden
.g.i.cs
files, as long as it's robust/reliable).Beta Was this translation helpful? Give feedback.
All reactions