问题
I'm running a CI build on a TFS build controller, connected to VS Online. I've got a 'Could not resolve this reference' problem for a NuGet package and I've observed behavior that I haven't seen before:
Locally the pacakage is downloaded to packages\FluentValidation.5.5.0
whereas on the server, it's downloaded to packages\FluentValidation.5.5.0.0
.
Packages.config:
<package id="FluentValidation" version="5.5.0" targetFramework="net45" userInstalled="true" />
.csproj file $(SolutionDir)
for shared project - works for all the other projects:
<Reference Include="FluentValidation, Version=5.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\FluentValidation.5.5.0\lib\Net40\FluentValidation.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
Nuget package restore is enabled, so if I locally remove the package from the packages folder and rebuild - works fine.
Now on the CI server. Build diagnostics log states:
Installing 'FluentValidation 5.5.0.0'. ... Successfully installed 'FluentValidation 5.5.0.0'.
But then further in build log:
16>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FluentValidation". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\Builds\24353... stuff...\projectfile.csproj] For SearchPath "{HintPathFromItem}". Considered "C:\Builds\24353... stuff ...\packages\FluentValidation.5.5.0\lib\Net40\FluentValidation.dll",
As expected - there's not package in that folder
C:\Builds\24353\... stuff ...\packages\FluentValidation.5.5.0\lib\Net40\
.
However - that's because it is downloaded into a different folder on the CI server:
C:\Builds\24353\... stuff ...\packages\FluentValidation.5.5.0.0\lib\Net40\
.
( note the extra .0 behind the package folder name ).
I have no idea where that extra .0 comes from. Also the project seems to ignore the build path. The CI server has VS 2013 on it and I updated NuGet on the box, didn't help. There's only 1 place where there's 5.5.0.0 ( with 2 zeros ) that's in the reference. I removed the trailing .0. Solution still builds locally, but not on CI.
Update Adding a 2nd hintpath in the .csproj file seems to fix the build on CI server, but breaks it locally. I really can't get my head around why it's v5.0.0 locally and v5.0.0.0 on the CI server.
P.S. I've reported it as bug: https://github.com/NuGet/Home/issues/504
回答1:
Turns out it was a bug in NuGet, which is fixed in the VS2015 RC:
Source: https://github.com/NuGet/Home/issues/504
来源:https://stackoverflow.com/questions/29939947/could-not-resolve-this-reference-nuget-on-ci-server