指定 Nuget 使用 特定的 vs MSBUILD 版本

                                                               Nuget 使用 特定的 vs MSBUILD 版本

当机器上同时装多个VS时,比如2019 and vs 2017,发现即使使用 vs 2017的Developer Command Prompt for VS 2017, nuget 命令是自动检测 2019的 编译器。 如下:

这样会导致原来在 vs 2017中能够顺利编译的项目将出现各种问题。

比如,可能是这样的一个错误, 实际上 roject.assets.json是存在的,可是因为项目restore 不正确,导致有些lib找不到而不正确定位到该文件。
Error    NETSDK1004    Assets file '...\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.    MainUI    C:\Program Files\dotnet\sdk\2.1.508\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets

通过指定msbuild 的版本后,发现编译终于正确执行

此外,发现Nuget restore 后面其实还有很options可以选择,如下:

参考:

https://github.com/NuGet/Home/issues/7621

https://blog.walterlv.com/post/specify-msbuild-version-for-nuget-command-line.html

发布了32 篇原创文章 · 获赞 7 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/mochounv/article/details/99290934