What / why is Roslyn “needed” in /bin folder of Asp.Net

前端 未结 5 1891
-上瘾入骨i
-上瘾入骨i 2020-12-05 09:05

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 prov

相关标签:
5条回答
  • 2020-12-05 09:38

    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

    0 讨论(0)
  • 2020-12-05 09:38

    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.

    0 讨论(0)
  • 2020-12-05 09:42

    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+

    0 讨论(0)
  • 2020-12-05 09:47

    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.

    0 讨论(0)
  • 2020-12-05 09:51

    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.

    0 讨论(0)
提交回复
热议问题