Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure automatic build failed

I have recently created project on visualstudio.com, and enabled continuous build on azure. I created web api project, and created some models and api controllers. Then I deployed it online and it was cool for a good while. Then I updated all dependencies through NuGet. Build went fine on local and also app worked on my local machine. Then I checked in to tfs, and automatic deploying kicked in, with build error. It says:

C:\a\src\HitchStopApi\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets (74): The "EnsureBindingRedirects" task could not be loaded from the assembly C:\a\src\HitchStopApi\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.Tasks.dll. Could not load file or assembly 'file:///C:\a\src\HitchStopApi\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

On my local machine build I get warning for Tests project

D:\Programming\Projects\HitchStop\HitchStopApi\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets(220,5): warning : Project must install nuget package Microsoft.Bcl.

On local I use .NET 4.5, MVC4, Entity framework 5.0...

like image 507
Dejan Stuparic Avatar asked Jun 09 '13 15:06

Dejan Stuparic


2 Answers

This is somewhat of a bug and is logged in several places. Bcl.Build isn't a project required to build on TFS, so you simply need to tell TFS not to include it if it doesn't exist. To do this, open up your .csproj file (for each project that references Bcl.Build) and change the following:

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets" />

to add a condition:

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets')" />

Note: If you update Bcl.Build via Nuget, it will also update your project file and the following will need to be done again. Create a second copy of this and comment it out if you don't want to lose it every update/have a reference.

Related References (same issue, different manifestation):

http://social.msdn.microsoft.com/Forums/en-US/TFService/thread/7bd2e96b-552a-4897-881c-4b3682ff835e

https://connect.microsoft.com/VisualStudio/feedback/details/788981/microsoft-bcl-build-targets-causes-project-loading-to-fail

https://nuget.codeplex.com/workitem/3135

Update: Microsoft wrote an official blog on this. While the above does work in some situations, its not a guarantee. Microsoft and the NuGet team are working together on a solution, but in the meantime have provided 3 (better?) workaround options:

http://blogs.msdn.com/b/dotnet/archive/2013/06/12/nuget-package-restore-issues.aspx

  1. Stop using package restore and check-in all package files
  2. Explicitly run package restore before building the project
  3. Check-in the .targets files
like image 93
roadsunknown Avatar answered Sep 24 '22 15:09

roadsunknown


Your problem is described here Solution: 1. Add dummy project (NugetHelper for example), add package.config with

<package id="Microsoft.Bcl.Build" version="1.0.6" targetFramework="net45" />
  1. Open Menu -> Project -> ProjectDependencies and make NugetHelper to build before other projects in solution

  2. Replace

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets" />

with

<Import Project="..\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.6\tools\Microsoft.Bcl.Build.targets')" />

this will restore Microsoft.Bcl.Build.targets before actually loading it in your main project

like image 32
Andriy F. Avatar answered Sep 24 '22 15:09

Andriy F.