Replies: 1 comment
-
The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using roslyn (Microsoft.CodeAnalysis.CSharp, Microsoft.CodeAnalysis.CSharp.Workspaces) in a .NET Framework v4.6.2 console application. I dynamically create the syntax tree and build it (Emit) into an assembly. This assembly target framework and version was the same as the console application framework and version so it was quite straightforward to do that. That worked without issues.
Now, in this very console application, using the same logic I want to build (Emit) an assembly targeting UWP. I'm completely stuck. Somewhere I found a few hints to use a TargetFrameworkAttribute. I tried that. I was even able to generate an assembly targeting .NET Standard by adding [assembly: TargetFramework("netstandard2.0")] but that is not what I need. That only proved that TargetFrameworkAttribute works at least in some cases. I particularly need to target UWP. I tried "uap", "uap10.0", "netcore50", ".NETCore,Version=v5.0", "win10" as the TargetFrameworkAttribute string. Nothing gives me the desired result.
I found another hint that most likely I need to specify RuntimeMetadataVersion for the Emit in the EmitOptions but I have no idea what to specify there. Also, I don't fully understand what to do with the references. For the .NET Framework I specified "mscorlib.dll", "System.Core.dll", "Serialize.Linq.dll". That was all that I needed for my dynamically generated code. It seems that for UWP I should not specify "mscorlib.dll". I analyzed other UWP assemblies, none of them have a direct reference to "mscorlib.dll". But if I don't specify it I get an error that I have to specify RuntimeMetadataVersion. For the UWP I tried this list of references "UAP\System.Runtime.dll", "UAP\System.Collections.dll", "UAP\Serialize.Linq.Universal.dll". Basically, I used a list that I found in another UWP assembly with the similar code.
Can anybody share an example how to use Roslyn and generate UWP assembly when the Roslyn is used in a .NET Framework console application?
Beta Was this translation helpful? Give feedback.
All reactions