5
votes

Running into an issue were project compiles locally just fine, but TFS build is reporting that assemblies cannot be found.

Log file will show:

2>C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1696,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "HtmlAgilityPack". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\Builds\1\MyProj\MyProj-Dev-Site\src\MyProj\MyProj.Domain\MyProj.Domain.csproj] For SearchPath "{HintPathFromItem}". Considered "..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll", but it didn't exist.

The issue I have is that there is most certainly a /packages/ folder in the location:

C:\Builds\1\MyProj\MyProj-Dev-Site\src\MyProj\packages\

Is the relative hint path somehow different on the TFS server? Seems like it would be relative to the .csproj file it was inspecting. I can confirm on the build output folder that the package (and DLL) are exactly where the HintPath specifies it should be.

Update: I found the solution to my issue. It's two-fold. One is that I cannot read file explorer and failed to notice that my HtmlAgilityPack folder only had the package's XML file, not the actual DLL. Second, I had to remove the 'packages' folder from TFS by going to 'Source Control Explorer' and removing that from my project. TFS handled the rest. Everything builds properly now.

More info: http://robertgreiner.com/2013/09/team-foundation-service-build-error-nuget/

1
Which version of TFS? Automatic package restore is only available on TFS 2013 update 3 and up. If your build server is still running a prior version it' will not work.MrHinsh - Martin Hinshelwood
I'll get back to you on it. Do you feel it's related to package restore though? The package files and binaries are on the build server, I can see them when I remote in.Kyle B.
Unless someone added the reference manually, and even then, all the paths should be relative.MrHinsh - Martin Hinshelwood
Yeah, it's relative in the HintPath when looking at the .csproj file. The confusing part for me, is that relative to the .csproj file in the HintPath for the assembly, that matching file is exactly where it says it should be. Also, we are currently on SP2 for TFS2013. It is being upgraded, so I can report if that resolves the issue.Kyle B.
it was the wrongly committed packages folder!reckface

1 Answers

2
votes

Since there's no official answer here (even though the OP put it above):

Update: I found the solution to my issue. It's two-fold. One is that I cannot read file explorer and failed to notice that my HtmlAgilityPack folder only had the package's XML file, not the actual DLL. Second, I had to remove the 'packages' folder from TFS by going to 'Source Control Explorer' and removing that from my project. TFS handled the rest. Everything builds properly now.

It seems that something about the way the build is run from TFS, if the "packages" folder already exists, even in a perfectly good location, even in the expected relative location that works locally, MSBuild just will not accept that location and prefers to recursively search all of the .targets directories instead. Anyway I can confirm that deleting the ..\packages folder works in VS2015/TFS2013.