Visual Studio在线等——这种情况下如何处理nuget包?

Visual Studio Online - How to deal with nuget packages in this situation?

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

当我在线签到 Visual Studio 时,会触发构建。此构建配置为检索 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.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>

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

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

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

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

保存并提交.. 对我有用。