I am generating a .NET Dll dynamically containing wrapper classes for a WPF Project. I am doing it with the System.CodeDom.Compiler.CodeDomProvider class.
Now I have to create a wrapper class for a Universal-Windows-Dll.
Since the System.CodeDom.Compiler.CodeDomProvider
class still uses the old .NET Compiler I had to Switch to the new Roslyn Compiler (by adding the Nuget Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
).
Then I replaced the instantiation of the code-dom-Provider with the new CSharpCodeProvider
.
new Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider();
The Code compiles fine but I found no way to set the TargetFramework / CompilerVersion.
The old CodeDomProvider
had the CompilerOptions
where I was able to specify the CompilerVersion
ect. But the new Roslyn does not have this Option (or I was to stupid to find it).
The result is that it compiles the DLL as a normal .NET 4.x Dll. But I Need a Universal-Windows Dll since it is used in a Universal-Project.
Browsing the Internet I found many different ways to use the Roslyn Compiler. Most of them seem to be from old Beta-Versions of the Compiler, therefore none of them works.
The Roslyn.Compilers
Namespace (which was used in most examples) seems to be the Namespace from the betas.
Does someone know how to use the roslyn Compiler properly? I don't want to modify the Compiler. I simply want to generate a DLL dynamically by compiling it from SourceCode, but I have to specify the Platform Target.