Reputation: 488
I'm importing a .NET core project on a windows 10 computer. It's a solution with a mvc project and a test project. When omnisharp is loading it throws multiple errors.
The first one:
movie-data\imdb_id_retrieval\imdb_id_retrieval.csproj(0,0): Error: Version 2.2.203 of the .NET Core SDK requires at least version 16.0.0 of MSBuild. The current available version of MSBuild is 15.9.21.664. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
Alright, so I updated visual studio to make sure I had MSBuild 16.0. To double check I ran
C:\Users\mcdonago\source\repos\movie-data> dotnet msbuild -version
Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
16.0.450.56488
PS C:\Users\mcdonago\source\repos\movie-data>
Still have this error when omnisharp is starting.
The second error:
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. c:\Users\mcdonago\source\repos\movie-data\imdb_id_retrieval\imdb_id_retrieval.csproj
People suggested I get the most recent SDK.
PS C:\Users\mcdonago\source\repos\movie-data> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.203
Commit: e5bab63eca
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.203\
Host (useful for support):
Version: 2.2.4
Commit: f95848e524
.NET Core SDKs installed:
2.2.203 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
PS C:\Users\mcdonago\source\repos\movie-data>
There's only one sdk and it's the most recent. People suggested I change my Project sdk reference to "Microsoft.Net.Sdk" instead of "Microsoft.Net.Sdk.Web". This allows omnisharp to successfully load the problem but then I have tons of errors such as
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) (CS0246) [imdb_data_retrieval_test]
which seems to be another whole mess of issues.
Note that both of my projects compile and run successfully so it makes me think it's an issue with omnisharp? Also, on my linux computer with vs code at home it works fine. Any help would be appreciated. I've been banging my head for a few hours and trying tons of things but can't get vs code to work with this solution.
edit: Here's my .csproj files.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.9.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
</ItemGroup>
</Project>
--
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0" />
<PackageReference Include="moq" Version="4.10.1" />
<PackageReference Include="nunit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\imdb_id_retrieval\imdb_id_retrieval.csproj" />
</ItemGroup>
</Project>
Upvotes: 1
Views: 912
Reputation: 639
it could be also in you app.Start.cs service section , try services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
Upvotes: 0
Reputation: 1573
I do not know what could be causing the issue, you setup looks fine, only some remarks
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
Should not be necessary, since Microsoft.AspNetCore.App
should include all the dependencies.
Also, you should not have the version specified in the reference, so, it should look something like
<PackageReference Include="Microsoft.AspNetCore.App" />
Form what I understand, your main project (the first csproj) is the one with problems? I have run to some troubles changing Net Core version because some libraries does not work as expected in the new versions, you could also create a new project and add one dependency at time, compiling between changes (you can do it with a simple empty project), so you can discard if is some library that is causing the problem.
For example, this is one of our csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
<PackageReference Include="Prometheus.Client.AspNetCore" Version="2.2.0" />
<PackageReference Include="Prometheus.Client.HttpRequestDurations" Version="1.2.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="System.Net.Primitives" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\vtae.common\vtae.common.csproj" />
<ProjectReference Include="..\vtae.data\vtae.data.csproj" />
<ProjectReference Include="..\vtae.integrations\vtae.integrations.csproj" />
</ItemGroup>
</Project>
Also check if you have a global.json config file and that the version there is right
Upvotes: 1