首页 > 解决方案 > 如何在 svn 中使用 NuGet 包?

问题描述

在我的项目中安装了一些 NuGet 包。packages.config 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr3.Runtime" version="3.5.1" targetFramework="net461" />
  <package id="FluentNHibernate" version="2.1.2" targetFramework="net461" />
  <package id="Iesi.Collections" version="4.0.4" targetFramework="net461" />
</packages>

我提交了我的项目并在另一个位置(同一台计算机)上对其进行了更新。但是现在当我尝试构建项目时出现以下错误:

1>------ Build started: Project: OnlineApplicationMapping, Configuration: Release Any CPU ------
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FluentNHibernate, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Iesi.Collections, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>C:\branches\Version\OnlineApplicationMapping\Mapping\ONLINE_ANTRAG_TYPMap.cs(1,7,1,23): error CS0246: The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?)
1>C:\branches\Version\OnlineApplicationMapping\Mapping\ONLINE_BEFUELL_MAPMap.cs(1,7,1,23): error CS0246: The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?)
1>C:\branches\Version\OnlineApplicationMapping\Mapping\ONLINE_ANTRAG_TYPMap.cs(11,34,11,61): error CS0246: The type or namespace name 'ClassMap<>' could not be found (are you missing a using directive or an assembly reference?)
1>C:\branches\Version\OnlineApplicationMapping\Mapping\ONLINE_BEFUELL_MAPMap.cs(11,35,11,63): error CS0246: The type or namespace name 'ClassMap<>' could not be found (are you missing a using directive or an assembly reference?)

似乎 NuGet-Packages 中的 dll 丢失了。

我真的必须将 dll 放在存储库中吗?在这种情况下,NuGet 不应该从某个服务器获取文件吗?

标签: c#svnnuget-package

解决方案


好的。我终于在 Austin T French 和 felix-b 的帮助下得到了这个(见评论)。我尝试遵循https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting章节中的命令:“其他潜在情况”

这就是我所做的:

  • 我关闭了 Visual Studio
  • 我删除了“包”文件夹(在解决方案文件夹中)
  • 我从这里下载了最新的 NuGet.exe:https ://www.nuget.org/downloads
  • 我从命令行调用了“nuget locals all -clear”。
  • 我重新打开了 Visual Studio
  • 我右键单击解决方案(在 VS 中)并选择:“恢复 Nuget 包”
  • 我重建了解决方案

推荐阅读