安裝vs2017后,再用vs2015打開xproj項目的時候會報錯:
Error MSB4019 The imported project "C:\Program Files\dotnet\sdk\1.0.0-rc3-004530\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk
但是,用vs2017打開這個項目的話,會提示你升級。測試了下,升級后就能打開了。
那么如何用vs2015打開該項目呢?
這時候就需要自己指定vs2015使用的sdk,需要在sln文件所在文件夾下新建文件global.json文件。假如我有兩個xproj的項目:a和b,sdk需要使用:1.0.0-preview2-1-003177,則文件如下:
{
"projects":[
"APISource.Web",
"APISourceWithHybrid.Web",
"APISourceWithJS.Web",
"ClientCredentialsAndPassword.Web",
"ClientCredentialsAndPassword.Web.Tests",
"HybridServer.Web",
"HybridServer.Web.Tests",
"ImplicitServer.Web",
"ImplicitServer.Web.Tests",
"ImplicitServerWithJS.Web",
"JavaScriptClient.Web.Tests"
],
"sdk":{
"version":"1.0.0-preview2-1-003177"
}
}
這時候打開項目就沒問題了!
你也可以自己測試下。打開cmd,
在global.json文件所在目錄輸入:dotnet --version,會顯示:1.0.0-preview2-1-003177
在其他目錄下會輸出:1.0.3
說明使用global.json文件的確可以手動指定使用的sdk。
