gpt4 book ai didi

asp.net-web-api - 什么/为什么 Roslyn "needed"在 Asp.Net 的/bin 文件夹中

转载 作者:行者123 更新时间:2023-12-04 06:43:06 26 4
gpt4 key购买 nike

有一堆related questions对此,尽管大多数答案都定义了 Roslyn 和/或为某些问题提供了“修复”( exe ,托管服务提供商等)

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

我遇到了类似的问题(托管 - .exe 限制、对 4.6 的支持等),我的“修复”是“仅部署到 Azure”(当然,一切都可以顺利进行)。但实际上,这并没有回答:

  • 为什么需要它们?
  • 这是否意味着它们用于 runtime编译(我的大脑指出了这一点,但这是一个完整的猜测/我可能错误的理解),如 this SO post shows - 除非更正,否则就是“它”(更多内容见下文)。
  • 似乎“删除包”是“修复”(based on some past answers) ,但如果是这样,它(重新)回避了这个问题

  • 我认为理解这会有所帮助 - 例如我不可能是唯一一个看到 .exe 会扬起眉毛的人“需要”……

    更新

    去表明“隐藏的 gem ”存在:) 我有 read this over and over ...毕竟它已经存在一段时间了 - 但是 不是 评论线程 - 原始引用链接,大约 2014 年,已由 Microsoft 重新设计,不再显示评论......幸运的是相关部分在下面。

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

    Dmitry Dzygin 2 Jun 2015 12:53 AM

    I have tried the latest version of the NuGet package, but there's seem to be a difference in the way the compiler is loaded/executed.

    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 2 Jun 2015 1:22 PM

    @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.



    嗯...

    更新:10/2017

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

    answer below by @Donny V是一种选择。通过完全编译您的应用程序,包括所有 Views ( .cshtml/ .vbhtml ),你不需要那个 exe在您的应用程序中。

    即使 Visual Studio(直到今天,VS 2017,令人困惑)仍会创建 /bin/roslyn,也是如此。它的内容在 Publish处理, 即使设置了“完全编译” .

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

    警告 :

    如前所述,完全编译您的应用程序意味着您必须重新编译它,即使对于 View水平变化。

    最佳答案

    这是摘自 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

    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.



    只是想让任何看到这个问题的人都知道卸载它的后果以及为什么它首先存在

    关于asp.net-web-api - 什么/为什么 Roslyn "needed"在 Asp.Net 的/bin 文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33740123/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com