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



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

    • 解决方案1WebApp
      • 程序包(文件夹)
      • Project1(文件夹)
        • 项目1.csproj
      • NuGet.config
      • 解决方案1.sln
    • 解决方案2库
      • 程序包(文件夹)
      • Project1(文件夹)
        • 项目1.csproj
      • Project2(文件夹)
        • 项目2.csproj
      • NuGet.config
      • 解决方案2.sln
    • 解决方案3单元测试
      • 程序包(文件夹)
      • Project1(文件夹)
        • 项目1.csproj
      • Project2(文件夹)
        • 项目2.csproj
      • Project3(文件夹)
        • 项目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>....Solution1WebApppackagesNewtonsoft.Json.7.0.1libnet45Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

但是构建一直失败,我收到这样的警告:

C:Program Files (x86)MSBuild14.0binamd64Microsoft.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>..packagesNewtonsoft.Json.7.0.1libnet45Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

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

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

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

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

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

最新更新