我的一台PC无法构建.Net网络核心应用程序(.Net核心2.2.301)。
mkdir c:\TEMP
cd c:\TEMP
dotnet new console
dotnet run
上面的命令将出现以下错误。
PS C:\TEMP> dotnet run C:\Users\xxx\AppData\Local\Temp\1\.NETCoreApp,Version=v2.2.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(10,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(11,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(12,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(13,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(14,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(15,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(16,12): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] C:\Users\xxx\AppData\Local\Temp\1\.NETCoreApp,Version=v2.2.AssemblyAttributes.cs(4,71): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] C:\Users\xxx\AppData\Local\Temp\1\.NETCoreApp,Version=v2.2.AssemblyAttributes.cs(4,99): error CS0246: The type or namespace name 'FrameworkDisplayName' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] C:\Users\xxx\AppData\Local\Temp\1\.NETCoreApp,Version=v2.2.AssemblyAttributes.cs(4,122): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(10,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(11,61): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(12,59): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(13,68): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(14,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(15,53): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(16,55): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] Program.cs(1,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] C:\Users\xxx\AppData\Local\Temp\1\.NETCoreApp,Version=v2.2.AssemblyAttributes.cs(2,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] C:\Users\xxx\AppData\Local\Temp\1\.NETCoreApp,Version=v2.2.AssemblyAttributes.cs(3,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(7,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] obj\Debug\netcoreapp2.2\TEMP.AssemblyInfo.cs(8,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [C:\TEMP\TEMP.csproj] Program.cs(5,11): error CS0518: Predefined type 'System.Object' is not defined or imported [C:\TEMP\TEMP.csproj] Program.cs(7,26): error CS0518: Predefined type 'System.String' is not defined or imported [C:\TEMP\TEMP.csproj] Program.cs(7,16): error CS0518: Predefined type 'System.Void' is not defined or imported [C:\TEMP\TEMP.csproj] The build failed. Please fix the build errors and run again.
在完成确切步骤之后,我将obj\project.assets.json
文件与另一台PC的文件进行了比较。在另一台PC上创建的应用程序可以运行并打印“ Hello World”。
区别是无法正常工作的人错过了所有包含“ .... dll”的行。
是dotnet restore
的问题吗?如何在PC上修复它?