Asp.Net 的/bin 文件夹中“需要”Roslyn 的内容/原因

关于这个问题有一大堆的 相关问题,尽管大多数的答案是 定义罗斯林和/或提供一些问题的“修复”(exe,托管服务提供商,等等)

我似乎无法追踪到的是 /bin/roslyn中的“为什么”和“为什么”(也许只是在 ASP.Net MVC/Web API 的上下文中)。

我遇到了类似的问题(主机-.exe限制,对 4.6的支持等等) ,我的“修复”是 “只要部署到 Azure”(当然所有的工作都没有问题)。但实际上,这并不能回答:

  • 为什么需要他们?
  • 这是否意味着他们是用于 runtime编译 (我的大脑指向这一点,但这完全是一个猜测/我可能错了) ,正如这篇 SO 文章所显示的-除非更正,这是“它”(更多见下文)。
  • 看来“移除包”是一个“修复”(基于一些过去的答案)但如果是这样,就回避了问题

我认为 理解这将有所帮助-例如,我不能是唯一一个谁会扬起眉毛看到 .exe“需要”..。


更新

展示了“隐藏的宝石”的存在:)我有 一遍又一遍地读这个... 毕竟它已经存在了一段时间了-但是 < strong > < em > not 评论帖子-最初的参考链接,大约2014年,已经被微软重新设计,评论不再显示... 幸运的是,相关部分在下面。

大错特错——它一直盯着我看(至少从这次交流开始) :

Dmitry Dzygin 2015年6月2日12:53 AM

我已经尝试了 NuGet 包的最新版本,但似乎在加载/执行编译器的方式上有所不同。

在 v0.2.0.0版本中,罗斯林编译器将被加载到内存中,大大提高了未预编译网站的性能 多个 * . as * x/* . cshtml 文件 新的 /bin/roslyn/csc.exe文件,每个文件执行一次, 完全删除上述优化特性... ...

黄金:

XMao 2 Jun 20152015年6月2日下午1:22

@ Dmitry /bin/Roslyncsc.exe的作用是调用位于同一文件夹中的 VBCSCompiler.exe 是执行实际编译工作的进程 VBCSCompiler 已经在运行 csc.exe,因此我们将重用它 仍然获得了上述的性能提高

这..。


更新: 2017年10月

看起来这是相关的,毕竟这么多时间,所以进一步更新。

作者:@Donny V选择。通过完全编译您的应用程序,包括所有的 Views(.cshtml/.vbhtml) ,您将不需要在您的应用程序中使用该 exe

即使 Visual Studio (到今天为止,令人困惑的是 VS 2017)将 还是创建 /bin/roslyn及其在 Publish进程 即使设置了“完整编译”中的内容,也是如此。

您可以通过 不包括测试这个 /bin/roslyn文件夹和它的内容时,推您的应用程序到您的托管提供商。

警告 :

如前所述,完全编译应用程序意味着您必须重新编译它,即使是对于 View级别的更改。

62882 次浏览

Another feature of it is that it does not require build servers to actually have compiler dependencies. You send the compiler you want to use WITH the code to the build server and it just uses exactly what you told it to.

This is taken from MSDN forum.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/442b100a-2b88-4ac4-b655-0c1345791f15/roslyn-cscexe-web-api-2-on-hosting-server?forum=msbuild

I have noticed a minor drawback to uninstalling this package:

https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform

Some of the new C# 6.0 language features if used in Views (MVC project) will not compile. Many of my views use the ?. null checking operator for accessing Model properties. All of these views now return errors on my Godaddy hosted MVC 5 application.

This error occurs because Views (by default) are compiled at runtime using the .NET pipeline (not pre-compiled).

To resolve this issue, simply uncheck the "Allow precompiled site to be updatable" option in your publish profile settings. This should pre-compile your views and allow your C# 6.0 (Latest version of Roslyn Compiler) to run like a champ.

Just wanted anyone looking at this question to know the ramification of uninstalling it and why its there in the first place

Was running into this issue all the time in Visual Studio 2017 Community Edition where the project could not be rebuilt because the older files in bin/roslyn could not be deleted. Based on the OP's Gold comment, I now keep the Task Manager open (Ctrl+Shift+Esc) and kill the VBCS.exe process. The offending files in bin/roslyn can now be deleted.

This release of Visual Studio contains a new version of C# & VB.net compilers code named “Roslyn”.

Roslyn is a complete rewrite of the C# and VB.net compilers with each written in their respective language for example the C# compiler is written in C# rather than C++. Roslyn is open source (Roslyn on GitHub) so you could even theoretically create your own version of C# or VB.net!

What would become Roslyn, was first mentioned way back in 2008 by Anders Hejlsberg at the PDC conference however it wasn’t until 2011 that the first preview was released.

You could refer to the following links to get more detailed information about your problem.

https://gooroo.io/GoorooTHINK/Article/16253/Visual-Studio-2015-and-Roslyn-Compiler/17944#.VmkfwjaheM8

https://visualstudiomagazine.com/articles/2012/03/20/10-questions-10-answers-on-roslyn.aspx

From: https://forums.asp.net/t/2079727.aspx?What+is+the+roslyn+folder+

Two things to note: 1) Removing it will "fix" the problem, but it "fix"es it by falling back to a built-in, old, legacy compiler that is not compatible with later language features.
2) Pre-compiling is not possible in many cases. How would you show information in a model if it's pre-compiled, and then show changes to that data? Any data that you rely on in partial views to refresh would never update.

Another point of interest is to make sure you are tracking the "build" directory in the roslyn's package. If you don't, it won't thrown an error but it will not compile your site when you try to load it. Fully tracked, it just works. We deployed it to other development systems without installing it on those systems first, and this is possible because it's a NuGet package.