title: What / why is Roslyn "needed" in /bin folder of Asp.Net
body: <p>There are a bunch of <a href="https://stackoverflow.com/search?q=bin+roslyn">related questions</a> on this, though most of the answers <em>define</em> Roslyn and/or provide a "fix" to some issue (<code>exe</code>, with hosting providers, etc.)</p>
  
  <p>What I can't seem to track down is the "why" and "what for" (perhaps only in the context of ASP.Net MVC/Web API) in <code>/bin/roslyn</code>.</p>
  
  <p>I ran in to similar issues (hosting - <code>.exe</code> restrictions, support for <code>4.6</code>, etc.) and my "fix" was to <em>"just deploy to Azure"</em> (of course everything works without a hitch). But really, this doesn't answer:</p>
  
  <ul>
  <li><strike>why are they needed?</strike></li>
  <li>does this mean that the they are used for <code>runtime</code> compilation <strike>(my brain  points to this, but that is a complete guess/my perhaps wrong grok), as <a href="https://stackoverflow.com/q/32282880/304683">this SO post shows</a></strike> - unless corrected, this is "it" (more below).</li>
  <li>it seems "removing the package" is a "fix" <a href="https://stackoverflow.com/a/32295103/304683">(based on some past answers)</a>, <strike>but if so, it (re)begs the question</strike></li>
  </ul>
  
  <p>I think <em>understanding</em> this will help - e.g. I can't be the only one who will have an eyebrow raised seeing an <code>.exe</code> "needed"....</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>Goes to show that "hidden gems" exist :) I've <a href="http://blogs.msdn.com/b/webdev/archive/2014/05/12/enabling-the-net-compiler-platform-roslyn-in-asp-net-applications.aspx" rel="noreferrer">read this over and over</a>...after all it's been there for some time now -  <strike>but <strong><em>not</em></strong> the comments thread</strike> - the original referenced link, circa 2014, has been redesigned by Microsoft and the comments are no longer displayed...luckily the relevant parts are below. </p>
  
  <p>BIG mistake - it was staring at me all this time (or at least since this exchange):</p>
  
  <blockquote>
    <p><em>Dmitry Dzygin 2 Jun 2015 12:53 AM</em></p>
    
    <p><em>I have tried the latest version of the NuGet package, but there's seem to be a difference in the way the compiler is loaded/executed.</em></p>
    
    <p><em>In the v0.2.0.0 the Roslyn compiler would be loaded into memory, improving greatly performance for not pre-compiled websites with
    multiple *.as*x/*.cshtml files. The new version, however, features a
    new <code>/bin/roslyn/csc.exe</code> file, which is executed once per file,
    completely removing the mentioned above optimization feature.....</em></p>
  </blockquote>
  
  <p>Gold:</p>
  
  <blockquote>
    <p><em>XMao 2 Jun 2015 1:22 PM</em></p>
    
    <p><em>@Dmitry The job of the <code>csc.exe</code> in <code>/bin/Roslyn</code> is to invoke the <code>VBCSCompiler.exe</code>, which sits in the same folder. <code>VBCSCompiler.exe</code>
    is the process that does the actual compilation work. If the
    VBCSCompiler is already running csc.exe will reuse it and thus we will
    still gain the mentioned performance improvement.</em></p>
  </blockquote>
  
  <p>Hth...</p>
  
  <hr>
  
  <h2>Update: 10/2017</h2>
  
  <p>Seems this is relevant after all this time so a further update. </p>
  
  <p>The <a href="https://stackoverflow.com/a/38309167/304683">answer below by @Donny V</a> is an <em>option</em>. By fully compiling your application, including all <code>Views</code> (<code>.cshtml</code>/<code>.vbhtml</code>), you wouldn't need that <code>exe</code> in your application.</p>
  
  <p>This is true even if Visual Studio (to this day, VS 2017, confusingly) will <em>still</em> create the <code>/bin/roslyn</code> and it's contents in the <code>Publish</code> process, <strong>even if "full compile" is set</strong>.</p>
  
  <p>You can test this by <em>excluding</em> the <code>/bin/roslyn</code> folder and it's contents when pushing your application to your hosting provider. </p>
  
  <p><strong>Caveat</strong>: </p>
  
  <p>As mentioned, fully compiling your application means you'll have to recompile it, even for <code>View</code> level changes.</p>