title: How to exclude Microsoft.CodeAnalysis.* DLLs from publishing
body: <p>I've written .NET Standard 2.1 library component that relies on Microsoft.AspNetCore.Mvc v2.2.0 package, which indirectly references Microsoft.CodeAnalysis.CSharp.dll, MicrosoftCode.Analysis.dll, and Microsoft.CodeAnalysis.Razor.dll. When I reference my component from .NET Core 3.1 app site and publish the site, Microsoft.CodeAnalysis.* dlls are also published. Is there a way to exclude Microsoft.CodeAnalysis.* dlls from being published? I don't need them for production.</p>
  <p>Here are my references from .NET Standard 2.1 CSPROJ file:</p>
  <pre><code> &lt;ItemGroup&gt;
  &lt;PackageReference Include=&quot;Microsoft.AspNetCore.Cryptography.KeyDerivation&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.AspNetCore.DataProtection.Abstractions&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.AspNetCore.Http.Features&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.AspNetCore.JsonPatch&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.AspNetCore.Mvc&quot; Version=&quot;2.2.0&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.AspNetCore.Razor.Language&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.CodeAnalysis.FxCopAnalyzers&quot; Version=&quot;3.3.0&quot;&gt;
    &lt;PrivateAssets&gt;all&lt;/PrivateAssets&gt;
    &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers&lt;/IncludeAssets&gt;
  &lt;/PackageReference&gt;
  &lt;PackageReference Include=&quot;Microsoft.DotNet.PlatformAbstractions&quot; Version=&quot;3.1.6&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.EntityFrameworkCore&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.Extensions.DependencyModel&quot; Version=&quot;3.1.6&quot; /&gt;
  &lt;PackageReference Include=&quot;Microsoft.Extensions.Identity.Core&quot; Version=&quot;3.1.8&quot; /&gt;
  &lt;PackageReference Include=&quot;Newtonsoft.Json&quot; Version=&quot;12.0.3&quot; /&gt;
  </code></pre>
    
  <p>Thanks in advance!</p>