MSBuild unable to locate NuGet references

Attempting to build a C# project which has numerous references to assemblies in NuGet packages fails in TeamCity but works fine in Visual Studio.

For SearchPath "{HintPathFromItem}".
[13:48:15][ResolveAssemblyReference]         Considered "..\packages\AspNetMvc.4.0.20126.16343\lib\net40\System.Web.Mvc.dll", but it didn't exist.


The reference in the project file is;

    <Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <Private>True</Private>
      <HintPath>..\packages\AspNetMvc.4.0.20126.16343\lib\net40\System.Web.Mvc.dll</HintPath>
    </Reference>




Any ideas? It seems like it's not starting from the correct directory so can't resolve "../packages" which exists one level above the .csproj file.


Thanks
10 comments
Comment actions Permalink

Any ideas?

Version is TeamCity Professional 7.0 (build 21241)

0
Comment actions Permalink

Hello,

Do you have all NuGet packages in the version control?
Do you use .nuget for automatically fetch packages?
Do you use NuGet Install runner in TeamCity to fetch missing packages?

Please include full build log.

0
Comment actions Permalink

Packages are under version control (not retrieved automatically) and the packages dir is present in TC's working dir. I'm not sure what the 'install runner' is, so no.


[12:05:26]Skip checking for changes - changes are already collected
[12:05:27]Publishing internal artifacts
[12:05:27]Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[12:05:27]Checkout directory: C:\TeamCity\buildAgent\work\4e7e3580cf5ffe05
[12:05:27]Updating sources: server side checkout
[12:05:27]Update assembly versions: scanning checkout directory for AssemblyInfo files to update version to 0.5.0.1400
[12:05:27]Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\4e7e3580cf5ffe05 /msbuildPath:C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
[12:05:27]in directory: C:\TeamCity\buildAgent\work\4e7e3580cf5ffe05
[12:05:29]TestNet\TestNet\TestNet.csproj.teamcity: Build targets: Rebuild;Package (1s)
[12:05:29][TestNet\TestNet\TestNet.csproj.teamcity] CleanReferencedProjects
[12:05:29][TestNet\TestNet\TestNet.csproj.teamcity] ResolveProjectReferences (1s)
[12:05:29][ResolveProjectReferences] MSBuild (1s)
[12:05:29][MSBuild] Fleet\DataAccessLayer\DataAccessLayer.csproj: Build default targets (1s)
[12:05:29][Fleet\DataAccessLayer\DataAccessLayer.csproj] ResolveProjectReferences (1s)
[12:05:29][ResolveProjectReferences] MSBuild (1s)
[12:05:29][MSBuild] Fleet\Models\Models.csproj: Build default targets (1s)
[12:05:29][Fleet\Models\Models.csproj] ResolveProjectReferences (1s)
[12:05:29][ResolveProjectReferences] MSBuild (1s)
[12:05:29][MSBuild] Fleet\Shared\Shared.csproj: Build default targets (1s)
[12:05:29][Fleet\Shared\Shared.csproj] ResolveAssemblyReferences
[12:05:29][ResolveAssemblyReferences] ResolveAssemblyReference
[12:05:29][ResolveAssemblyReference] Primary reference "System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL".
[12:05:29][ResolveAssemblyReference] c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360, 9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
[12:05:29][ResolveAssemblyReference]         For SearchPath "{HintPathFromItem}".
[12:05:29][ResolveAssemblyReference]         Considered "..\packages\System.Json.4.0.20126.16343\lib\net40\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         For SearchPath "{TargetFrameworkDirectory}".
[12:05:29][ResolveAssemblyReference]         Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.0,AssemblyFoldersEx}".
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v4.0\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v4.0\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         For SearchPath "{AssemblyFolders}".
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "c:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "C:\Program Files\IIS\Microsoft Web Deploy V2\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "C:\Program Files\IIS\Microsoft Web Deploy V2\System.Json.exe", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         For SearchPath "{GAC}".
[12:05:29][ResolveAssemblyReference]         Considered "System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL", which was not found in the GAC.
[12:05:29][ResolveAssemblyReference]         For SearchPath "{RawFileName}".
[12:05:29][ResolveAssemblyReference]         Considered treating "System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" as a file name, but it didn't exist.
[12:05:29][ResolveAssemblyReference]         For SearchPath "bin\Debug\".
[12:05:29][ResolveAssemblyReference]         Considered "bin\Debug\System.Json.dll", but it didn't exist.
[12:05:29][ResolveAssemblyReference]         Considered "bin\Debug\System.Json.exe", but it didn't exist.


**SNIP**

[12:05:29][Csc] Attributes\NoCacheAttribute.cs(3, 18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

0
Comment actions Permalink

Our buildserver is locked down from internet access so these aren't really an option, the packages must remain in the repo. This seems like a bug to me although maybe with MSBuild, I saw another user mention the issue happens when running MSBuild directly.

0
Comment actions Permalink

Please ensure all files from solution packages folder are checked in to version control.  That would be enough than.

0
Comment actions Permalink

They are so it doesn't seem to be.

It appears to be an MSBuild issue, I've just run it from the command line and it cannot locate assemblies with a <HintPath> of ..\packages\etc

0
Comment actions Permalink

Did anyone resolve this?  I am having the same issue.  

0
Comment actions Permalink

You may either configure NuGet Installer build runner prior to MSBuild script or try to use NuGet packages restore feature (that you may enable from Visual Studio)

0
Comment actions Permalink

The hint path's were wrong in the actual project files due to restructuring of the directories. Visual Studio could cope with this and find them some other way, MSBuild obviously has nothing else to go on and would fail if the path was incorrect.

0

Please sign in to leave a comment.