我安装了VS 2015并导入了现有的解决方案。 此解决方案在App_Code文件夹中包含Razor帮助程序。 错误列表抱怨:
名称空间'ASP'中不存在类型或命名空间名称'global_asax'(您是否缺少程序集引用?)
经过一些研究,我发现这是(或曾经)一个已知的问题(参见本回答和本文 )。 这些文章中给出的解决方案是手动安装Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet包。
所以我在我的网络应用程序项目中安装了NuGet包,错误就消失了。
但是,当我打开包管理器控制台抱怨它无法复制某些文件时,我现在收到错误。 Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet包配置信息中给出了丢失文件的(不正确)路径。
所有这些让我相信必须有更好的方法!
我错过了什么吗? 我不应该通过VS 2015自动获得新的Roslyn魔法吗? 如果没有,是否有更好的方法将它安装到我现有的项目中? 或者我只是绊倒了有人需要解决的破碎的基础设施位?
I installed VS 2015 and imported an existing solution. This solution contains a Razor helper in the App_Code folder. The Error List complains:
The type or namespace name 'global_asax' does not exist in the namespace 'ASP' (are you missing an assembly reference?)
After a bit of research, I found that this is (or was) a known issue (cf. This SO answer and this article). The solution given in those articles is to manually install the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package.
So I installed that NuGet package in my web app project, and the error went away.
But now I get an error when I open the Package Manager Console complaining that it can't copy some file. The (incorrect) path to the missing file is given in the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package configuration info.
All of this leads me to believe that there must be a better way!
Am I missing something? Shouldn't I get the new Roslyn magic automagically via VS 2015? If not, is there some better way for me to install it into my existing project? Or am I just stumbling over broken infrastructure bits that someone needs to fix?
最满意答案
我在VS 2015中创建了一个新的MVC应用程序,并盯着它安装的NuGet包。 事实证明,我们显然需要安装
Microsoft.Net.Compilers NuGet包
(而不是Microsoft.CodeDom.Providers.DotNetCompilerPlatform包)。
编辑:经过这个解决方案的更多摆弄后,它似乎并不比我在OP中提供的(失败的)解决方案更好。 但不要害怕,显然有一个答案(如果你正在运行VS 2015)。 我会将其作为一个单独的答案发布。
Per this MSDN blog post the solution is, in fact, to install the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package (which, I hope and assume, they have fixed since I tried that in July, 2015). There is even some magic baked into the VS 2015 UI to install that package via the Project menu.
更多推荐
发布评论