visual-studio-2017 - Visual Studio 2017 : how to include NuGet packages in solution folder

标签 visual-studio-2017 nuget .net-standard-2.0

迄今为止,使用 Visual Studio 2015,NuGet packagas 被恢复到特定于解决方案的“packages”文件夹中,我将其 checkin 到源代码管理中。我们的 TFS 构建服务器无法访问 Internet,因此它需要这些本地副本才能成功构建。

我现在正在尝试使用 .NETStandard 类库的 Visual Studio 2017,它不再制作 NuGet 包的本地副本 - 相反,它们似乎存储在 %HOMEDRIVE%%HOMEPATH%.nuget\packages 中。这意味着它们在构建服务器上不再可用。

如何让 NuGet 在本地存储包?

最佳答案

你应该能够定义一个 RestorePackagesPath property在您的 .NET Standard(SDK 样式)项目中,该项目定义了应将 NuGet 包还原到的位置。

您可以使用它来告诉 NuGet 不要使用 .nuget\packages 目录,而是使用与您的项目相关的其他目录。

<PropertyGroup>
  <RestorePackagesPath>..\path\to\MyPackages</RestorePackagesPath>
</PropertyGroup>

查看 NuGet documentation他们在使用使用 PackageReferences 的项目时提到了三种可能的方法。

  1. 将 NUGET_PACKAGES 环境变量设置为不同的文件夹。
  2. 创建一个 NuGet.Config 文件,将 globalPackagesFolder 设置为不同的文件夹。
  3. 使用 RestorePackagesPath MSBuild 属性指定不同的文件夹。

关于visual-studio-2017 - Visual Studio 2017 : how to include NuGet packages in solution folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49587080/

相关文章:

visual-studio - 如何修复Xamarin/NuGet错误NU1107? - "Version conflict detected for Xamarin.Android.Support.Compat"

powershell - 为 nuget 创建自定义 powershell 脚本,将自定义目标添加到 csproj BeforeBuild 步骤

claims-based-identity - 我们从哪里获得 .Net Standard 2.0 中的 System.IdentityModel

visual-studio - 在 Visual Studio 2017 15.7 中禁用 Screwdriver

c# - 在多包八达通作业中选择最新的包版本

c# - Visual Studio 不会在不重新启动的情况下在项目和 NuGet 引用之间切换

c# - 消息 - 更新 Azure 上的函数版本

c# - 无法在 2 个程序集(UWP、Splat)之间注册 View 和 ViewModel

.net-core - Visual Studio 中的构建前事件变量为空

c# - 为什么 C# 中的完整属性可以仅用 getter 覆盖但仍然可以设置?