I just created a simple "Hello World" console app to start testing .netcore 3.0 development on Linux using VS Code, and it won't compile with (currently) 26 errors, mostly stating that predefined types System.Object, System.String, System.Void etc are not defined or imported.
The.csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Project Include="Program.cs"/>
</ItemGroup>
</Project>
The Program.Main
using System;
namespace TestNetCore3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
What's interesting is I have the same problem with a classlib I've been working on, which compiles and runs (the tests) fine when on a Windows 10 machine, yet when I load the repo on my Linux machine it all falls apart at the seams.
Nice idea will be to check if you have instaled specified SDK, in this case for .NET 3.0.
You can do this by typing:
dotnet --list-sdks
for all installed SDK versions, or like it was pointed in comment by TiGreX by using:
dotnet --info
Also keep in mind, that for 3.0 Visual Studio Code require newest C# extension, so please check if you have it.
Turns out I had both 3.0.100 and 2.2.402 SDKs installed, which was causing a conflict. Uninstalling 2.2.402 did the trick
sudo rm -rf /usr/share/dotnet/sdk/2.2.402
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.