AppHarbor使用nuget包构建错误

时间:2014-02-07 05:32:16

标签: visual-studio-2012 nuget bitbucket appharbor

从bitbucket部署到AppHarbor时出现构建错误。它与其中一个项目无法解决应该来自Nuget的依赖项有关。一切都在我的机器上构建并运行良好。知识 - 我非常精通Nuget和经验丰富的开发人员。我可能是通过在本地移动文件夹并重新创建bitbucket repo来引起这种情况。我已经检查了bitbucket源代码,看起来一切都与本地相比。

我的解决方案结构类似于:

\repo\app.sln
\repo\model\model.csproj
\repo\web\web.csproj

model是核心/模型类库项目。 web是一个Web应用程序(webapi2 + html),它依赖于模型。两者都正确构建并在我的本地盒子上正常运行,但我最近遇到了Bitbucket的一些问题所以我在磁盘上移动了一些东西并创建了一个新的存储库。只有当它运到Appharbor时才打破了构建。

为两个项目启用了Nuget包恢复。

以下是AppHarbor构建过程的日志顶部:

Build started 2/7/2014 5:19:58 AM.
     1>Project "D:\temp\g0q2xqui.baf\input\app.sln" on node 1 (default targets).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Release|Any CPU".
     1>Project "D:\temp\g0q2xqui.baf\input\app.sln" (1) is building "D:\temp\g0q2xqui.baf\input\web\web.csproj" (2) on node 1 (default targets).
     2>RestorePackages:
         "D:\temp\g0q2xqui.baf\input\.nuget\NuGet.exe" install "packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "D:\temp\g0q2xqui.baf\input\ "
     1>Project "D:\temp\g0q2xqui.baf\input\app.sln" (1) is building "D:\temp\g0q2xqui.baf\input\model\model.csproj" (4) on node 2 (default targets).
     4>RestorePackages:
         "D:\temp\g0q2xqui.baf\input\.nuget\NuGet.exe" install "packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "D:\temp\g0q2xqui.baf\input\ "
     2>RestorePackages:
         Restoring NuGet packages...
         To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
         All packages listed in packages.config are already installed.
     4>RestorePackages:
         Restoring NuGet packages...
         To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
         All packages listed in packages.config are already installed.
       ResolveAssemblyReferences:
         Primary reference "MongoDB.Bson".
     4>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "MongoDB.Bson". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\temp\g0q2xqui.baf\input\model\model.csproj]
                 For SearchPath "{HintPathFromItem}".

如您所见,“模型”(#4)项目无法解析MongoRepository nuget包的引用。那个级联并破坏了构建。

这是模型项目的packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="mongocsharpdriver" version="1.8.3" targetFramework="net45" />
  <package id="MongoRepository" version="1.6.3" targetFramework="net45" />
</packages>

2 个答案:

答案 0 :(得分:1)

将HintPath更改为..\packages对我来说不起作用,但将其更改为$(Solutiondir)\packages对我来说就像魅力一样。

答案 1 :(得分:0)

csproj中有一些路径被破坏了:

  <ItemGroup>
    <Reference Include="MongoDB.Bson">
      <HintPath>..\web\packages\mongocsharpdriver.1.8.3\lib\net35\MongoDB.Bson.dll</HintPath>
    </Reference>
    <Reference Include="MongoDB.Driver">
      <HintPath>..\web\packages\mongocsharpdriver.1.8.3\lib\net35\MongoDB.Driver.dll</HintPath>
    </Reference>
    <Reference Include="MongoRepository.Net45, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\packages\MongoRepository.1.6.3\lib\net45\MongoRepository.Net45.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>

需要将HintPath更改为.. \ packages以删除Web目录。