Visual Studio Online - 如何在这种情况下处理nuget包?

时间:2015-11-17 09:40:59

标签: msbuild visual-studio-2015 nuget-package azure-devops

我们最近从一个大的SLN文件转移到多个SLN文件。所以现在文件夹结构是这样的:

    • Solution1WebApp
      • 包(文件夹)
      • Project1(文件夹)
        • Project1.csproj
      • NuGet.config
      • Solution1.sln
    • Solution2Libraries
      • 包(文件夹)
      • Project1(文件夹)
        • Project1.csproj
      • Project2(文件夹)
        • Project2.csproj
      • NuGet.config
      • Solution2.sln
    • Solution3UnitTests
      • 包(文件夹)
      • Project1(文件夹)
        • Project1.csproj
      • Project2(文件夹)
        • Project2.csproj
      • Project3(文件夹)
        • Project3.csproj
      • NuGet.config
      • Solution3.sln

当我在Visual Studio Online中办理登机手续时,会触发构建。此构建配置为检索nuget包(因此未签入包文件夹)。

在Solution1的csproj文件中,我将所有指向包的路径配置为:

<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\..\Solution1WebApp\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

但构建仍然失败,我得到这样的警告:

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1819, 5)  

    Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

我认为这些警告会导致例外情况:

The type or namespace name 'xxx' does not exist in the namespace 'yyy' (are you missing an assembly reference?)

所以我错过了什么?路径是否正确配置?

感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

好的,我找到了答案。包路径必须没有解决方案名称:

<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

在VSO构建定义中,我为每个解决方案添加了构建步骤(库的一个步骤,一个用于单元测试,一个用于Web应用程序)。

这样,每个解决方案都在构建,路径可以与我们PC上的本地路径保持一致。

答案 1 :(得分:0)

删除在packages.json文件中提及的引用和项目。

将它们添加回其找不到文件的解决方案中的项目。

保存并提交..为我工作。

相关问题