title: How can I add an icon to my compiled file via Roslyn?
body: <p>I tried this:</p>
  <pre><code>static void Main(string[] args)
  {
      var fileToCompile = @&quot;C:\Users\User\Desktop\test.cs&quot;;
      var source = File.ReadAllText(fileToCompile);
      var parsedSyntaxTree = Parse(source, &quot;&quot;, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Latest));
  
      var compilation
          = CSharpCompilation.Create(&quot;Test.exe&quot;, new SyntaxTree[] { parsedSyntaxTree }, DefaultReferences, DefaultCompilationOptions);
      try
      {
  
          var result = compilation.Emit(@&quot;C:\Users\User\Desktop\Test.exe&quot;, null, null, &quot;C:\testicon.ico&quot;);
  
          Console.WriteLine(result.Success ? &quot;Sucess!!&quot; : $@&quot;Failed, {result}&quot;);
      }
      catch (Exception ex)
      {
          Console.WriteLine(ex);
      }
      Console.Read();
  }
  </code></pre>
  <p>But I get an error saying :</p>
  <blockquote>
  <p>error CS1583: Error reading Win32 resources -- Win32 resources, assumed to be in COFF object format, are missing one or both of sections '.rsrc$01' and '.rsrc$02'</p>
  </blockquote>
  <p>I tried with different icons but still same error. Without adding an icon works fine.</p>