为什么在ASP.NET Core网站上发布Microsoft.CodeAnalysis? [英] Why is Microsoft.CodeAnalysis published with ASP.NET Core website?
问题描述
我正在发布一个ASP.NET Core MVC 3.0网站,并且输出文件夹中包含许多语言的许多参考资料,这些内容引用了Microsoft.CodeAnalysis
库,有人知道为什么吗?
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?
当然FxCopAnalyzers
Nuget软件包已安装在项目上,但未在项目的早期版本中发布,因此我不明白为什么会这样,因为它只在开发时才有用.在生产环境中.
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.
推荐答案
以多种语言包含了对Microsoft的大量引用.CodeAnalysis库
contains lots of reference in many language to Microsoft.CodeAnalysis librairies
当我使用3.0版本时,确实遇到了相同的问题.但是我不认为这是由.net core 3编译出版物上的视图引起的,因为还有
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.
-
我相信你是正确的.这些分析应仅在devtime时使用.
I believe you're correct. These Analysis should be used at devtime only.
但是,当我手动卸载 SDK(3.0)并再次安装最新的SDK 时,我无法再复制了.我不知道为什么会发生这种情况,也许现在已经解决了.这很可能是由另一个原因引起的:我偶然地对依赖于Microsoft.CodeAnalysis的其他软件包添加了额外的参考.无论如何,请先将您的SDK升级到最新版本.
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.
另一个重要的事情是,当使用Visual Studio添加控制器时,它将在 Microsoft.VisualStudio.Web.CodeGeneration.Design
上自动添加引用.
请注意,此程序包间接依赖于Microsoft.CodeAnalysis.Common
程序包. Microsoft.CodeAnalysis.Common
是Microsoft .NET编译器平台("Roslyn")使用的共享软件包.如果下载此软件包并手动解压缩该lib,则会发现其中有一个Microsoft.CodeAnalysis.dll
:
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/
仅在开发时间需要此软件包.如果不删除此依赖项,则在发布文件夹中将获得很多与Microsoft.CodeAnalysis
相关的dll.
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>
删除依赖于Microsoft.CodeAnalysis
的那些程序包,然后您将不会获得与Microsoft.CodeAnalysis
相关的dll:
Remove those packages that depends on Microsoft.CodeAnalysis
, and then you should get no Microsoft.CodeAnalysis
related dlls:
这篇关于为什么在ASP.NET Core网站上发布Microsoft.CodeAnalysis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!