【发布时间】:2018-07-02 16:11:30
【问题描述】:
我无法从头开始构建任何 .Net Core 2.1 控制台应用程序(或任何类型的 .Net Core/ASP.Net Core 应用程序)。我在下面发布了一个屏幕截图,显示了错误(缺少依赖项/引用)并在解决方案资源管理器中圈出了依赖项,因为有一个黄色感叹号。我还在下面列出了“dotnet --info”命令以及尝试构建后的“输出”窗口。我一生都无法弄清楚为什么我的机器没有在我的机器上找到 Nuget 包/引用。我真的很感激任何帮助。我已经尝试过很多事情,比如发出“dotnet restore”命令。删除 NugetPackageFallBack 文件夹,修复 Visual Studio 并获取所有更新。我在 Windows 10 机器 x64 上使用 Visual Studio 15.7.4。
“dotnet --info”的输出
C:\Projects\JDB_POC>dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.300
Commit: adab45bf0c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300\
Host (useful for support):
Version: 2.1.0
Commit: caa7b7e2ba
.NET Core SDKs installed:
1.0.4 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Notice the yellow exclamation around the dependencies in the Solution Explorer
输出窗口的输出:
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 '
【问题讨论】:
-
是的,我已经阅读了这些内容。我确实尝试删除 NugetFallback 文件夹。我还尝试修复 .Net 2.1 SDK,尝试运行“dotnet nuget locals all --clear”命令等。如果有人想查看,我会看看是否可以包含 MSBuild.log。我想放弃这个,因为我花了太多时间试图编译一个项目:(。
标签: c# asp.net visual-studio .net-core