title: .NET Core Assembly.LoadFile at PostBuild event
body: <p>I need generate <code>typescript</code> files from some of my C# classes after build.</p>
  
  <p>I created <code>dotnet cli tool</code> and added post-build event</p>
  
  <pre><code>dotnet tsgenerator "$(TargetPath)"
  </code></pre>
  
  <p>where <code>$(TargetPath)</code> is macros pointing, for example, <code>D:\Test\bin\Release\netcoreapp2.0\my.dll</code></p>
  
  <p>Next, i tried to load assembly next way:</p>
  
  <pre><code>public static void Main(string[] args)
  {
      var dllPath = args[0]; // "D:\Test\bin\Release\netcoreapp2.0\my.dll"
      var assembly = Assembly.LoadFile(dllPath);
      var types = assembly.GetExportedTypes(); // Throws exception
  }
  </code></pre>
  
  <p>But i got <code>ReflectionTypeLoadException</code> that says <code>Could not load file or assembly</code> for some references assemblies (for example, <code>Microsoft.AspNetCore.Antiforgery</code>).</p>
  
  <p>How i can load assembly for .NET Core applications?</p>