Project file is incomplete. Expected imports are missing 错误解决方案

当你打开一个.net core的项目,Visual Studio 可能无法打开,提示如下错误:

D:workshopGithubOcelotsrcOcelotOcelot.csproj : error  : Project file is incomplete. Expected imports are missing.

D:workshopGithubOcelot estOcelot.UnitTestsOcelot.UnitTests.csproj : error  : Project file is incomplete. Expected imports are missing.

D:workshopGithubOcelot estOcelot.AcceptanceTestsOcelot.AcceptanceTests.csproj : error  : Project file is incomplete. Expected imports are missing.

D:workshopGithubOcelot estOcelot.ManualTestOcelot.ManualTest.csproj : error  : Project file is incomplete. Expected imports are missing.

D:workshopGithubOcelot estOcelot.BenchmarksOcelot.Benchmarks.csproj : error  : Project file is incomplete. Expected imports are missing.

D:workshopGithubOcelot estOcelot.IntegrationTestsOcelot.IntegrationTests.csproj : error  : Project file is incomplete. Expected imports are missing.

D:workshopGithubOcelotsrcOcelotOcelot.csproj : error  : Project file is incomplete. Expected imports are missing.

这个错误的原因是项目通过global.json 指定了项目的SDK版本,比如Ocelot的global.json 指定了2.1.301

{
   "projects": [ "src", "test" ],
   "sdk": {
     "version": "2.1.301"
   }
}

我的机器上没有安装这个版本的SDK,解决方法就是安装这个版本的SDK。

原文地址:https://www.cnblogs.com/shanyou/p/9626854.html