罗斯林“需要"什么/为什么?在 Asp.Net 的/bin 文件夹中 [英] What / why is Roslyn "needed" in /bin folder of Asp.Net

查看:19
本文介绍了罗斯林“需要"什么/为什么?在 Asp.Net 的/bin 文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一堆相关问题,尽管大多数答案定义em> Roslyn 和/或提供对某些问题的修复"(exe、托管服务提供商等)

There are a bunch of related questions on this, though most of the answers define Roslyn and/or provide a "fix" to some issue (exe, with hosting providers, etc.)

我似乎无法追查到的是 /bin/roslyn 中的为什么"和为什么"(也许仅在 ASP.Net MVC/Web API 的上下文中).

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 /bin/roslyn.

我遇到了类似的问题(托管 - .exe 限制、对 4.6 的支持等),我的修复"是只是部署到 Azure"(当然一切正常).但实际上,这并没有回答:

I ran in to similar issues (hosting - .exe restrictions, support for 4.6, etc.) and my "fix" was to "just deploy to Azure" (of course everything works without a hitch). But really, this doesn't answer:

  • 为什么需要它们?
  • 这是否意味着它们用于runtime编译(我的大脑指出了这一点,但这是一个完整的猜测/我可能是错误的grok),如此 SO 帖子显示 - 除非更正,否则就是它"(更多内容见下文).
  • 似乎删除包"是一个修复"(基于过去的一些答案)但如果是这样,它(重新)回避了这个问题

我认为理解这会有所帮助 - 例如我不可能是唯一一个看到需要".exe 时皱眉的人....

I think understanding this will help - e.g. I can't be the only one who will have an eyebrow raised seeing an .exe "needed"....

表明存在隐藏的宝石":) 我已经一遍又一遍地阅读...毕竟它已经存在一段时间了 - 但是不是评论线程 - 原始引用链接,大约在 2014 年,已由 Microsoft 重新设计,评论不再显示......幸运的是相关部分在下面.

Goes to show that "hidden gems" exist :) I've read this over and over...after all it's been there for some time now - but not the comments thread - the original referenced link, circa 2014, has been redesigned by Microsoft and the comments are no longer displayed...luckily the relevant parts are below.

大错误 - 它一直盯着我看(或者至少自从这次交流以来):

BIG mistake - it was staring at me all this time (or at least since this exchange):

Dmitry Dzygin 2015 年 6 月 2 日上午 12:53

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

在 v0.2.0.0 中 Roslyn 编译器将被加载到内存中,大大提高了非预编译网站的性能多个 *.as*x/*.cshtml 文件.然而,新版本具有新的 /bin/roslyn/csc.exe 文件,每个文件执行一次,完全去掉上面提到的优化功能.....

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 /bin/roslyn/csc.exe file, which is executed once per file, completely removing the mentioned above optimization feature.....

黄金:

XMao 2015 年 6 月 2 日下午 1:22

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

@Dmitry The job of the csc.exe in /bin/Roslyn is to invoke the VBCSCompiler.exe, which sits in the same folder. VBCSCompiler.exe 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.

第...

似乎这很重要,因此需要进一步更新.

Seems this is relevant after all this time so a further update.

@Donny V 下面的 答案 是一个选项.通过完全编译您的应用程序,包括所有 Views (.cshtml/.vbhtml),您就不需要那个 exe代码>在您的应用程序中.

The answer below by @Donny V is an option. By fully compiling your application, including all Views (.cshtml/.vbhtml), you wouldn't need that exe in your application.

即使 Visual Studio(直到今天,VS 2017,令人困惑)将仍然创建 /bin/roslyn 及其在 中的内容也是如此发布过程,即使设置了完全编译".

This is true even if Visual Studio (to this day, VS 2017, confusingly) will still create the /bin/roslyn and it's contents in the Publish process, even if "full compile" is set.

您可以通过排除/bin/roslyn 文件夹以及将您的应用程序推送到您的托管服务提供商时的内容来测试这一点.

You can test this by excluding the /bin/roslyn folder and it's contents when pushing your application to your hosting provider.

警告:

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

As mentioned, fully compiling your application means you'll have to recompile it, even for View level changes.

推荐答案

本文摘自 MSDN 论坛.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/442b100a-2b88-4ac4-b655-0c1345791f15/roslyn-cscexe-web-api-2-on-hosting-server?forum=msbuild

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

如果在视图 (MVC项目)将无法编译.我的许多观点都使用 ?.空值检查用于访问模型属性的运算符.所有这些观点现在在我的 Godaddy 托管的 MVC 5 应用程序上返回错误.

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.

出现这个错误是因为视图(默认)是在运行时编译的使用 .NET 管道(未预编译).

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

要解决此问题,只需取消选中允许预编译站点可更新"选项在您的发布配置文件设置中.这应该预编译您的视图并允许您的 C# 6.0(最新版本的 Roslyn编译器)像冠军一样运行.

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

这篇关于罗斯林“需要"什么/为什么?在 Asp.Net 的/bin 文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆