Why is Microsoft.CodeAnalysis published with ASP.NET Core website?

牧云@^-^@ 提交于 2019-12-01 06:14:53

问题


I'm publishing an ASP.NET Core MVC 3.0 website and the output folder contains lots of reference in many language to Microsoft.CodeAnalysis librairies, someone knows why?

Of course the FxCopAnalyzers Nuget package is installed on the project, but it was not published in an earlier version of the project, so I don't understand why it is now since it should be useful only at dev time not in a production environment.


回答1:


contains lots of reference in many language to Microsoft.CodeAnalysis librairies

I did encounter the same issue when I used the 3.0 version. But I don't think it's caused by .net core 3 compiling views on publication because there's also View ViewCompilation in the release/2.1 branch .


it should be useful only at dev time not in a production environnement.

  1. I believe you're correct. These Analysis should be used at devtime only.

  2. But when I uninstall the SDK(3.0) manually and install the latest SDK again, I can't not reproduce any more. I don't why it happens, maybe it has been fixed now. It is more likely caused by another reason: I added an extra reference on other packages that depends on Microsoft.CodeAnalysis by accident). Anyway, please upgrade your SDK to the latest version firstly.

  3. Another important thing is, when using Visual Studio to add controller, it will add a reference on Microsoft.VisualStudio.Web.CodeGeneration.Design automatically. Note this package has a dependency on Microsoft.CodeAnalysis.Common package indirectly. Here the Microsoft.CodeAnalysis.Common is a shared package used by the Microsoft .NET Compiler Platform ("Roslyn"). If you download this package and unzip this lib manually, you'll find that there's a Microsoft.CodeAnalysis.dll :

    microsoft.codeanalysis.common.3.3.1/
    ├───lib/
    │   └───netstandard2.0/
    │       ├─── ...
    │       ├─── Microsoft.CodeAnalysis.dll
    │       ├─── Microsoft.CodeAnalysis.pdb
    │       ├─── Microsoft.CodeAnalysis.xml
    │       └─── ...
    ├───package/
    │   └───...
    └───_rels/
    

    This package is only needed at Dev-Time. If you don't remove this dependency, you'll get quite a lot of dlls related to Microsoft.CodeAnalysis in your publish folder.

    <ItemGroup>
        <!-- this is not necessary when publishing -->
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
    </ItemGroup>
    

    Remove those packages that depends on Microsoft.CodeAnalysis, and then you should get no Microsoft.CodeAnalysis related dlls:



来源:https://stackoverflow.com/questions/58291135/why-is-microsoft-codeanalysis-published-with-asp-net-core-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!