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

Msbuild Visual Studio Online-在这种情况下如何处理nuget软件包?,msbuild,visual-studio-2015,nuget-package,azure-devops,Msbuild,Visual Studio 2015,Nuget Package,Azure Devops,我们最近从一个大型SLN文件转移到多个文件。现在文件夹结构如下所示: <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\..\Solution1WebApp\packages\Newtonsoft.Json.7.0.1\lib\n

我们最近从一个大型SLN文件转移到多个文件。现在文件夹结构如下所示:

<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.
    • 解决方案1WebApp
      • 软件包(文件夹)
      • 项目1(文件夹)
        • Project1.csproj
      • NuGet.config
      • 解决方案1.sln
    • 解决方案2图书馆
      • 软件包(文件夹)
      • 项目1(文件夹)
        • Project1.csproj
      • 项目2(文件夹)
        • 项目2.csproj
      • NuGet.config
      • 解决方案2.sln
    • 解决方案3单元测试
      • 软件包(文件夹)
      • 项目1(文件夹)
        • Project1.csproj
      • 项目2(文件夹)
        • 项目2.csproj
      • 项目3(文件夹)
        • 项目3.csproj
      • NuGet.config
      • 解决方案3.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?)
我是不是错过了什么?路径配置是否正确


谢谢你的帮助。

好的,我找到了答案。包路径必须保留,且不包含解决方案名称:

<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>

..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
真的
在VSO构建定义中,我为每个解决方案添加了一个构建步骤(一个步骤用于库,一个步骤用于单元测试,一个步骤用于Web应用)


通过这种方式,每个解决方案都在构建中,路径可以与我们电脑上的本地路径保持相同。

删除packages.json文件中提到的引用和项目

将它们重新添加到解决方案中找不到文件的项目中


保存并提交。。为我工作

我不认为把单元测试和主题分开是个好主意。您应该有两个解决方案,都包含单元测试和它们测试的代码…感谢MrHinsh的提示。为了清楚起见,我没有在这里提到它,但是是的,web应用程序引用了单元测试项目,因此在打开web应用程序时,我们拥有所有可用的内容。