Quantcast
Channel: WE MOVED to github.com/nuget. This site is not monitored!
Viewing all articles
Browse latest Browse all 7612

Edited Issue: NuGet 2.2.1 - Build fails on TFS build controller using Package Restore due to changes in NuGet.Targets [3050]

$
0
0
#Overview and Workaround

I'm using Visual Studio/TFS 2012 and have package restore enabled locally and on my TFS build controller. Package restore works fine locally in 2.2.1, but fails on the build controller - was working fine for both in 2.2. This is a similar issue to [2745](http://nuget.codeplex.com/workitem/2745), but different in that I'm not using a pre-build event that relies on a package.

I am using the _repositoryPath_ config setting in a local .nuget/NuGet.Config file contained in the solution:

```
<config>
<add key="repositoryPath" value="..\..\..\..\..\..\_Packages" />
</config>
```

This is a problem with a small change to the <RestoreCommand> element in NuGet.targets that appears to have been made.

Previously, this line was...

```
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreCommand>
```

... and now is:

```
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -o "$(PackagesDir)"</RestoreCommand>
```

I was able to fix the TFS build problem by changing the __-o "$(PackagesDir)"__ back to __-solutionDir "$(SolutionDir) "__ in the <RestoreCommand>.

#Build Controller Failure Details

In the MSBuild log file for the failed build, I can see that package restore successfully downloads missing packages:

```
2>RestorePackages:
"d:\Builds\1\Confidential\Path\Omitted\.nuget\nuget.exe" install "d:\Builds\1\Confidential\Path\Omitted\packages.config" -source "" -RequireConsent -o "d:\Builds\1\Confidential\Path\Omitted\packages"
Successfully installed 'jQuery.Validation 1.11.0'.
Successfully installed 'Microsoft.AspNet.Mvc 4.0.20710.0'.
(others successfully installed, Netwonsoft.Json, Underscore.js, etc ...)
```

Notice the 'packages' folder specified at the end of the path for the -o option. It seems like this should respect the value of the _repositoryPath_ config setting but not sure. In any case, assembly resolution fails later in the build:

```
3>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [d:\Builds\1\Confidential\Path\Omitted\MyProject.csproj]
For SearchPath "{HintPathFromItem}".
Considered "..\..\..\..\..\_Packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll", but it didn't exist.

```
The hint path is correct based on my _repositoryPath_ config setting. When I replace the <RestoreCommand> with the older version as described above, everything works fine.

Viewing all articles
Browse latest Browse all 7612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>