如何在没有 project.assets.json 或 nuget restore 的情况下使用 msbuild? [英] How can I use msbuild without project.assets.json or nuget restore?

查看:49
本文介绍了如何在没有 project.assets.json 或 nuget restore 的情况下使用 msbuild?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个解决方案中有一个 .Net Standard 项目,我希望 msbuild 在我们的构建服务器上构建它.如果我不先运行nuget restore",我会收到错误project.assets.json' not found. Run a NuGet package restore".我已经在解决方案级别的包"文件夹中拥有所有必要的 NuGet 包.我想以某种方式表明 msbuild 应该只使用本地包"文件夹中的文件,而不是尝试重新下载文件.我怎样才能做到这一点?谢谢.

I have a .Net Standard project in a solution and I want msbuild to build it on our build server. If I do not run "nuget restore" first, I get the error "project.assets.json' not found. Run a NuGet package restore". I already have all of the necessary NuGet packages in the "packages" folder at the solution level. I would like to indicate somehow that msbuild should just use the files in the local "packages" folder instead of trying to re-download the files. How can I do this? Thank you.

推荐答案

.NET Standard 项目不使用解决方案中的 packages 文件夹.这是通过 packages.config 引用 NuGet 包的旧"方式.新方法 - 项目中的 PackageReference 项 - 使用用户主目录中的共享全局包文件夹.即使不需要下载任何包,也需要在构建机器上重新生成 project.assets.json 并使用该共享缓存的解析路径.事实上,如果所有程序包都在机器上,NuGet 还原甚至可能不需要访问网络.

.NET Standard projects do not use the packages folder in the solution. This is the "old" way of referencing NuGet packages through packages.config. The new way - PackageReference items in the project - uses a shared global packages folder in the user's home directory. The project.assets.json needs to be regenerated on the build machine with the resolved paths to this shared cache even if no packages need to be downloaded. In fact, a NuGet restore might not even need to hit the network if all packages are already on the machine.

这篇关于如何在没有 project.assets.json 或 nuget restore 的情况下使用 msbuild?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆