首页 > 解决方案 > dotnet restore 不复制 NETStandard.Library 和其他框架包

问题描述

我有一台不允许连接到任何网络的 PC。我需要在这台 PC 上进行网络标准项目。我之前曾在这种情况下使用过 Net Framework 项目,只是使用 nuget.exe 选项将包保存到文件夹,将文件夹复制到隔离的 PC 并使用 nuget 从该文件夹恢复包。

但是使用 dotnet restore 机制对 Net Standard 项目执行此操作会失败,因为缺少像 NETStandard.Library 这样的包。

我用来创建离线包文件夹的命令是:

dotnet restore solution.sln --packages offline_cache

将文件夹复制到我使用的隔离机器后:

dotnet restore solution.sln --source offline_cache

标签: c#.net.net-corenuget.net-standard

解决方案


听起来你想运行dotnet publish https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish

请注意,如果您使用的是 PackageReferences,则nuget restore只会在全局缓存中安装依赖项,而不是在本地复制它们https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore


推荐阅读