Is it possible to build a .NET core or better a .NET standard library with Roslyn that can be referenced from another project?
My goal is to build an assembly on the server and have people download it so they can reference and use it in their own Visual Studio projects.
I'm using Roslyn to generate C# code and compile it. This seems to work ok when I "emit" the compilation result to a memory stream, load the assembly from that and execute the code using reflection.
using (var ms = new MemoryStream())
{
var compilationResult = compilation.Emit(ms);
if (compilationResult.Success)
{
ms.Position = 0;
var assembly = AssemblyLoadContext.Default.LoadFromStream(ms);
..
..
Is can also "save" the assembly by proving a path to the Emit method. This results in a .dll file on disk.
var compilationResult2 = compilation.Emit(@"D:\testassembly.dll");
I wonder what kind of format this .dll file is. It doesn't seem to be a "normal" assembly.
I searched the internet but couldn't find anyone doing this. Do I misunderstand something?
So my questions are:
- What kind of format is the file create by Emit? Is it a full/normal assembly? I'm confused here because when I open it with DotPeek it shows:
I would expect a .net standard or .net core assembly. Also i'm not able to use this assembly by referencing it from another project in Visual Studio.
- Is it possible to generate an assembly using Roslyn that can be referenced from a separate .net core project?
Thanks
