【问题标题】:Visual Studio Online - The type or namespace name yyy does not exist in the namespace xxxVisual Studio Online - 名称空间 xxx 中不存在类型或名称空间名称 yyy
【发布时间】:2015-08-06 17:14:56
【问题描述】:

我有一个使用 .NET Framework 4.6 的 Visual Studio 2015 解决方案。在本地,我可以毫无问题地进行编译,并且我使用的是最新版本 (3.1) 的 NuGet。

当我签入然后使用 Visual Studio Online 构建时,我收到如下错误:

  • Plumbing\DALContainerRegistration.cs (1):命名空间“Microsoft”中不存在类型或命名空间名称“Practices”(您是 缺少程序集参考?)
  • Storage\BlobStorage.cs (5):命名空间“Microsoft”中不存在类型或命名空间名称“WindowsAzure”(您是 缺少程序集参考?)

我知道我在构建服务器上缺少这些引用,但我不知道如何解决这个问题。在上面的两个示例中,我从 NuGet 获取了企业库和 Azure 存储库,因此显然没有理由不工作。

我的 sln 根目录有一个 NuGet.config,它的内容如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

你知道哪里出了问题吗?如果您需要任何其他信息,请告诉我。

【问题讨论】:

  • 你的目标构建框架是什么?
  • 您是否在解决方案中启用了包还原选项?转到工具 > NuGet 包管理器 > 包管理器设置。对话框打开后,展开 NuGet 包管理器。在“常规”选项卡中,确保选中 Allow NuGet to download missing packagesAutomatically check for missing packages during build in Visual Studio
  • @bowlturner: .NET Framework 4.6
  • @SwDevMan81:是的,这些选项已启用

标签: c# visual-studio-2015 nuget tfsbuild azure-devops


【解决方案1】:

您需要启用Restore NuGet Packages。在 VSO Build vNext 中,您可以在 Build 步骤中执行此操作。

要创建新的构建定义:

【讨论】:

  • 感谢 Lukkha Coder,我如何才能访问此 UI?
  • xxx.visualstudio.com/DefaultCollection/OE/ENG/… 将 xxx 替换为您的网址。
  • 恐怕不行,我也把OE换成了我的收藏名……我要新建一个收藏吗?我的收藏是在 vNext 4 月发布之前创建的...
  • 你没有。但是,您需要检查您的构建是使用旧的 Xaml TeamBuild 还是新的 VSO Build vNext。
  • Ok Lukkha,我可以在我当前的项目中找到访问这些选项的位置,我只需从 VSO 门户创建一个新版本。所以我尝试了这个新的构建,不幸的是我仍然有错误:Unable to find version '5.0.505.0' of package 'EnterpriseLibrary.Caching'. Unable to find version '5.0.505.0' of package 'EnterpriseLibrary.Caching.Cryptography'. Unable to find version '6.0.1304.0' of package 'EnterpriseLibrary.Common'. Unable to find version '6.0.1304.0' of package 'EnterpriseLibrary.Logging'. Unable to find version '5.6.2' of package 'Microsoft.Data.Edm'.
【解决方案2】:

我可以通过如下修改 NuGet.config 文件来解决这个问题:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="nuget.orgv3" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <disabledPackageSources />
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>

【讨论】:

    猜你喜欢
    • 2015-12-13
    • 1970-01-01
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    • 2020-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多