简体   繁体   English

Visual Studio 2017的.NET Core 1.1构建和类识别错误

[英].NET Core 1.1 build and class recognition bug on Visual Studio 2017

I have recently started developing a test project on the latest .NET Core version 1.1 and I have been experiencing considerable amount of issues though most of them could be solved by browsing the web. 我最近开始在最新的.NET Core版本1.1上开发测试项目,尽管大多数问题都可以通过浏览Web来解决,但是我遇到了很多问题。 I am currently using Visual Studio 2017 community . 我当前正在使用Visual Studio 2017社区

There is one particular annoying bug which involves the following (some steps to reproduce it): 有一个特别令人讨厌的错误,涉及以下内容(重现该错误的一些步骤):

  • Use the command line interface and execute the dotnet build command at least once to build the project. 使用命令行界面并至少执行一次dotnet build命令以构建项目。
  • Open the solution and create a new class in a random folder in the solution. 打开解决方案,然后在解决方案的随机文件夹中创建一个新类。
  • Once the class is created I notice that there is no triangle-dropdown option for the new class. 创建班级后,我注意到新班级没有三角形下拉选项 It seems that for some reason the solution does not recognize the class that I just created and it cannot be referenced by other classes in the same solution. 似乎由于某种原因,该解决方案无法识别我刚刚创建的类,并且同一解决方案中的其他类无法引用该类。 All classes are public etc. so it is not a coding problem. 所有类都是公共类,因此这不是编码问题。 I also checked the build options and there are no differences between the problematic class and other classes in the solution. 我还检查了构建选项 ,有问题的类与解决方案中的其他类之间没有区别。
  • Then what I need to do is close the solution, execute the dotnet build command once again and then reopen the solution using the File > Open menu in Visual Studio. 然后,我需要做的是关闭解决方案,再次执行dotnet build命令,然后使用Visual Studio中的“ 文件”>“打开”菜单重新打开该解决方案。 Notice that if you reopen the solution from the Recent list it will NOT work and the class will still be unrecognized in the project structure. 请注意,如果从最近的清单重新打开该解决方案将无法正常工作和阶级仍然会在项目结构中无法识别。

I have to say that sometimes for unknown reasons even if I follow properly all the mentioned steps above the trick is not going to work and I have to reopen and build several times. 我不得不说,有时即使出于正确的原因,即使我正确地执行了上述所有步骤,此技巧仍无法正常工作,因此我不得不重新打开并构建几次。 There was a similar project build issue on .NET Core 1.0 as well (proper building only works by using the CLI ). .NET Core 1.0上也存在类似的项目构建问题(正确的构建只能通过使用CLI进行 )。

One issue I also notice in the 1.1 version is that after you create a new folder anywhere in the solution this folder will not appear in the .csproject file (in the ItemGroup xml tag) which also should not happen. 我在1.1版本中还注意到的一个问题是,在解决方案中的任何位置创建新文件夹后,该文件夹将不会出现在.csproject文件(位于ItemGroup xml标记中)中,这也不应该发生。 Basically it seems that the .csproj file is not reflecting any changes done to the solution. 基本上, .csproj文件似乎没有反映对解决方案所做的任何更改。

Could all of that be a caching issue ? 所有这些都可能是一个缓存问题吗?

So far the .NET Core technology has been really impressive to me clearly showing a brighter future for developers however I have been experiencing enormous amount of troubleshooting issues especially in the latest 1.1 version. 到目前为止,.NET Core技术确实给我留下了深刻的印象,为开发人员带来了光明的未来,但是我一直在遇到大量的故障排除问题,尤其是在最新的1.1版本中。

Regards, RF 问候,RF

Solution found: 找到解决方案:

I managed to find the source of the issue. 我设法找到问题的根源。 It seems that in Visual Studio 2017 a new option has been implemented called Lightweight solution load and this option is causing the issue of not recognizing new classes and references. 似乎在Visual Studio 2017中实现了一个称为``轻量级解决方案加载''的新选项,此选项导致无法识别新类和引用的问题。 Once I switched it off it worked as intended. 一旦关闭它,它就会按预期工作。 The Lightweight Solution Load option button appears next to the Open Folder in File Explorer and you might accidentally click it. 轻量级解决方案加载”选项按钮显示在“文件资源管理器”中的“ 打开文件夹 ”旁边,您可能会意外单击它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio 2017中创建.NET Core 3(每晚构建)应用程序? - How to create .NET Core 3 (nightly build) app in Visual Studio 2017? 在Visual Studio 2017中与IIS Express一起运行时,ASP.NET Core 1.1 Web应用程序无法启动 - ASP.NET Core 1.1 web application does not start when running with IIS Express in Visual Studio 2017 Visual Studio 2017 ASP.NET Core 中的 TFS 构建问题/错误 - TFS Build issue/error in visual Studio 2017 ASP.NET Core 使用Visual Studio 2015无法解析.NET Core 1.1中的项目 - Cannot resolve a project in .NET Core 1.1 using Visual Studio 2015 使用 Visual Studio 2017 以 .NET Framework 2.0(不是 .NET Core 2.0)为目标 - Target .NET Framework 2.0 (not .NET Core 2.0) with Visual Studio 2017 在Visual Studio 2017中生成.NET Core Console App .exe - Generating .NET Core Console App .exe in Visual Studio 2017 使用Visual Studio 2017的Asp Net Core 2.0的Crystal报表 - Crystal Report for Asp Net Core 2.0 With Visual Studio 2017 Visual Studio 2017 15.7.2 - 缺少 ASP.NET Core 应用程序 - Visual Studio 2017 15.7.2 - ASP.NET Core Application is missing Visual Studio 2017的Asp.net Core 2.0.0运行时错误 - Asp.net Core 2.0.0 runtime error with Visual Studio 2017 Visual Studio 2017新的.csproj是否与非.net核心项目相关 - Is Visual Studio 2017 new .csproj relevant to non .net core projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM