Search code examples
c#.net-corevisual-studio-codenugetomnisharp

VS Code / OmniSharp failing to load project; Can't find a package that is present


When I start up VS Code or restart OmniSharp, I get the following error message:

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/user/Documents/repos/proj/proj-backend/Application/Application.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        Package Microsoft.EntityFrameworkCore.Analyzers, version 3.1.5 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/user/Documents/repos/proj/proj-backend/Application/Application.csproj'.
/Users/user/Documents/repos/proj/proj-backend/Application/Application.csproj
/usr/local/share/dotnet/sdk/3.1.301/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): Error: Package Microsoft.EntityFrameworkCore.Analyzers, version 3.1.5 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.

Here is my csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <ItemGroup>
    <ProjectReference Include="..\Persistence\Persistence.csproj"/>
    <ProjectReference Include="..\Domain\Domain.csproj"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="MediatR" Version="8.0.0"/>
    <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="8.0.0"/>
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
    <PackageReference Include="RestSharp" Version="106.10.1"/>
    <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0"/>
    <PackageReference Include="StandardModels" Version="0.1.3.15"/>
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0"/>
    <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5"/>
    <PackageReference Include="EPPlus" Version="5.1.1"/>
    <PackageReference Include="AutoMapper" Version="9.0.0"/>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="3.1.5"/>
  </ItemGroup>
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
</Project>

dotnet restore --no-cache works fine and building/running has no errors. I tried removing Microsoft.EntityFrameworkCore.Analyzers but it doesn't make a difference.

Any ideas why I can't get this to load?

Thanks in advance!


Solution

  • I resolved this issue by deleting the entire repository, recloning, and creating a new workspace file. The combination of those actions did the trick.