C# 在.Net核心控制台应用程序中找不到依赖项-在启动时显示为缺失

C# 在.Net核心控制台应用程序中找不到依赖项-在启动时显示为缺失,c#,asp.net,visual-studio,.net-core,C#,Asp.net,Visual Studio,.net Core,我很难从零开始构建任何.Net Core 2.1控制台应用程序(或者任何类型的.Net Core/ASP.Net Core应用程序)。我在下面发布了一个屏幕截图,显示了错误(缺少依赖项/引用),并在解决方案资源管理器中圈出了依赖项,因为其中有一个黄色感叹号。我还列出了下面的“dotnet--info”命令以及尝试构建后的“Output”窗口。我一辈子都搞不懂为什么我的机器找不到我机器上的Nuget包/引用。我真的很感谢你的帮助。我试过很多方法,比如发出“dotnetrestore”命令。删除Nu

我很难从零开始构建任何.Net Core 2.1控制台应用程序(或者任何类型的.Net Core/ASP.Net Core应用程序)。我在下面发布了一个屏幕截图,显示了错误(缺少依赖项/引用),并在解决方案资源管理器中圈出了依赖项,因为其中有一个黄色感叹号。我还列出了下面的“dotnet--info”命令以及尝试构建后的“Output”窗口。我一辈子都搞不懂为什么我的机器找不到我机器上的Nuget包/引用。我真的很感谢你的帮助。我试过很多方法,比如发出“dotnetrestore”命令。删除NugetPackageFallBack文件夹,重新编写Visual Studio并获取所有更新。我正在Windows10机器x64上使用VisualStudio15.7.4

dotnet--info”的输出

输出窗口的输出:

1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,20,4,26): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(14,12,14,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(15,12,15,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(16,12,16,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(17,12,17,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(18,12,18,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(19,12,19,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(20,12,20,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,71,4,97): error CS0518: Predefined type 'System.String' is not defined or imported
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,99,4,119): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,122,4,124): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(14,55,14,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(15,61,15,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(16,59,16,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(17,68,17,75): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(18,55,18,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(19,53,19,66): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(20,55,20,64): error CS0518: Predefined type 'System.String' is not defined or imported
1>Program.cs(1,7,1,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(2,7,2,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(3,7,3,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(11,7,11,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(12,7,12,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>Program.cs(5,11,5,18): error CS0518: Predefined type 'System.Object' is not defined or imported
1>Program.cs(7,26,7,32): error CS0518: Predefined type 'System.String' is not defined or imported
1>Program.cs(7,16,7,20): error CS0518: Predefined type '

我也有类似的问题。我的工作项目突然丢失了nuget包。我尝试了上面的所有建议,例如删除NugetFallBack文件夹、清洁解决方案、dotnet还原等。没有一个有效。我尝试从头开始创建一个新项目,但在创建时缺少了一些包


解决这个问题的方法是在管理模式下打开Visual Studio。

您阅读了吗?是的,我已经阅读了这些内容。我确实尝试删除NugetFallback文件夹。我还尝试修复.Net 2.1 SDK,尝试运行“dotnet nuget locals all--clear”命令,等等。如果有人想查看,我将看看是否可以包含MSBuild.log。我想放弃这一点,因为我花了太多的时间试图编译一个项目:(。
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,20,4,26): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(14,12,14,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(15,12,15,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(16,12,16,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(17,12,17,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(18,12,18,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(19,12,19,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(20,12,20,18): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,71,4,97): error CS0518: Predefined type 'System.String' is not defined or imported
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,99,4,119): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,122,4,124): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(14,55,14,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(15,61,15,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(16,59,16,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(17,68,17,75): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(18,55,18,68): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(19,53,19,66): error CS0518: Predefined type 'System.String' is not defined or imported
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(20,55,20,64): error CS0518: Predefined type 'System.String' is not defined or imported
1>Program.cs(1,7,1,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(2,7,2,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\RossJ\AppData\Local\Temp\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(3,7,3,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(11,7,11,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>obj\Debug\netcoreapp2.1\ConsoleApp4.AssemblyInfo.cs(12,7,12,13): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
1>Program.cs(5,11,5,18): error CS0518: Predefined type 'System.Object' is not defined or imported
1>Program.cs(7,26,7,32): error CS0518: Predefined type 'System.String' is not defined or imported
1>Program.cs(7,16,7,20): error CS0518: Predefined type '