AppHarbor build error with nuget packages
Asked Answered
P

2

0

I'm getting a build error when deploying to AppHarbor from bitbucket. It's related to one of the projects not being able to resolve a dependency which should come from Nuget. Everything builds and runs fine on my machine. Knowledge - I am very well versed with Nuget and an experienced dev. I probably caused this by shuffling folders around locally and recreating the bitbucket repo. I've checked the bitbucket source and it seems everything is there compared to local.

My solution is structured similar to this:

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

model is a core/models class library project. web is a web application (webapi2 + html) which takes a dependency on model. Both build correctly and run fine on my local box, but I recently had some issues with Bitbucket so I moved stuff around on disk and created a new repository. This broke the build only when it gets shipped up to Appharbor.

Nuget package restore is turned on for both projects.

Here's the top of the log from AppHarbor build process:

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}".

As you can see the "model" (#4) project is unable to resolve references for the MongoRepository nuget package. That cascades and breaks the build.

Here's the packages.config for the model proj:

<?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>
Playpen answered 7/2, 2014 at 5:32 Comment(0)
P
0

There were some paths in the csproj that were broken:

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

Needed to change the HintPath to ..\packages to remove the web directory.

Playpen answered 7/2, 2014 at 20:54 Comment(0)
B
1

Changing the HintPath to ..\packages didn't work for me but changing it to $(Solutiondir)\packages worked for me like a charm.

Buhler answered 16/2, 2014 at 11:19 Comment(0)
P
0

There were some paths in the csproj that were broken:

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

Needed to change the HintPath to ..\packages to remove the web directory.

Playpen answered 7/2, 2014 at 20:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.