【问题标题】:Azure Devops not finding restored nuget packagesAzure Devops 找不到恢复的 nuget 包
【发布时间】:2019-10-30 12:42:57
【问题描述】:

我为一个 C# 项目创建了一个构建管道。

我引用了不同的 nuget 包,例如 Entity Framework 和一些位于提要中的自己的包。

整个解决方案在本地构建和运行没有问题。

同样在构建管道中,nuget restore 正在运行。但是构建失败了,因为它找不到 nuget 包。

这发生在像实体框架这样的公共包和我脚下的包上。

nuget 版本:

  • 检测到 NuGet 版本 4.1.0.2450 / 4.1.0

我尝试过构建版本、构建代理或创建自己的 nuget.config 文件。

我还卸载了 nuget 包,删除了所有引用并重新安装了每个包

例如:

##[error]paybla.Repository.EntityFramework\RepositoryBase.cs(3,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
RepositoryBase.cs(3,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\UnitOfWorkBase.cs(3,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
UnitOfWorkBase.cs(3,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\UnitOfWorkBase.cs(4,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
UnitOfWorkBase.cs(4,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\UnitOfWorkBase.cs(5,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
UnitOfWorkBase.cs(5,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\UnitOfWorkBase.cs(6,19): Error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
UnitOfWorkBase.cs(6,19): error CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\RepositoryBase.cs(11,26): Error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
RepositoryBase.cs(11,26): error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\UnitOfWorkBase.cs(15,26): Error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
UnitOfWorkBase.cs(15,26): error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
##[error]paybla.Repository.EntityFramework\UnitOfWorkBase.cs(157,19): Error CS0246: The type or namespace name 'IDbSet<>' could not be found (are you missing a using directive or an assembly reference?)
UnitOfWorkBase.cs(157,19): error CS0246: The type or namespace name 'IDbSet<>' could not be found (are you missing a using directive or an assembly reference?) [d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj]
Done Building Project "d:\a\3\s\paybla.Repository.EntityFramework\paybla.Repository.EntityFramework.csproj" (default targets) -- FAILED.

【问题讨论】:

  • 同样在构建管道中,nuget restore 正在工作 -- 它是工作,还是成功?这两件事不是一回事。即使构建活动没有按照您的预期进行,它也可以成功。查看还原日志。是恢复所有的包吗?有警告吗?
  • 这是一个很好的答案!事实上,我在日志中没有看到任何恢复的包。我不知道为什么我没有注意到这一点。配置链接:und-dann-los.de/wp-content/uploads/2019/06/Unbenannt.png 日志结尾说:packages.config 中列出的所有包都已安装。老实说..我不知道这里有什么问题
  • 使用自己的构建代理来重现问题,然后您可以进入实际工作目录进行进一步分析。在互联网上讨论此类内容过于广泛。
  • 您使用的是 Nuget Restore 还是 dotnet restore ?

标签: c# .net tfs azure-devops


【解决方案1】:

请尝试检查您是否已将 \packages 文件夹添加到源代码管理中,如果是,您可以从源代码管理中删除整个 packages 文件夹,看看是否可以解决问题。

【讨论】:

    【解决方案2】:

    可能与您的情况无关,但有时(特别是当允许 R# 引用丢失的包时)csproj 文件可能包含对本地驱动器上的程序集的引用 - 类似这样

    <ItemGroup>
      <Reference Include="name">
        <HintPath>../../your/local/path</HintPath>
      </Reference>
    </ItemGroup>
    

    删除所有此类节点并通过 nuget ui 手动添加包对我有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-14
      • 2019-08-17
      • 2019-07-21
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多