title: Generate assembly with Roslyn
body: <p>Is it possible to build a .NET core or better a .NET standard library with Roslyn that can be referenced from another project?</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>using (var ms = new MemoryStream())
  {
      var compilationResult = compilation.Emit(ms);
      if (compilationResult.Success)
      {
      ms.Position = 0;
  
      var assembly = AssemblyLoadContext.Default.LoadFromStream(ms);
  ..
  ..
  </code></pre>
  
  <p>Is can also "save" the assembly by proving a path to the Emit method. This results in a .dll file on disk.</p>
  
  <pre><code>var compilationResult2 = compilation.Emit(@"D:\testassembly.dll");
  </code></pre>
  
  <p>I wonder what kind of format this .dll file is. It doesn't seem to be a "normal" assembly.</p>
  
  <p>I searched the internet but couldn't find anyone doing this. Do I misunderstand something?</p>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>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:</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/HAZvc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HAZvc.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <ul>
  <li>Is it possible to generate an assembly using Roslyn that can be referenced from a separate .net core project?</li>
  </ul>
  
  <p>Thanks</p>