TFS 2010 Build - Lesson learned --> Treat warnings as errors

We came across a weird issue with our TFS 2010 build server. We have an MVC3 web application where we added a new Silverlight application. Since we added that Silverlight application our build fails. We get error messages like these:

#1
image C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets (1852): Copying file ClientBin\BuildAuction.xap to obj\Release\Package\PackageTmp\ClientBin\BuildAuction.xap failed. Could not find file 'ClientBin\BuildAuction.xap'.

#2
image Copying file C:\Builds\4\WoolTradePlus\WooltradePlus - Build and Test on Checkin\Binaries\BuildAuction.xap failed. Access to the path 'C:\Builds\4\WoolTradePlus\WooltradePlus - Build and Test on Checkin\Sources\trunk\WoolTradePlus\MvcApplicationXXX\ClientBin\BuildAuction.xap' is denied.

image
Figure: Spiderman and Batman to the rescue


Here is my journey to fix this problem

#1
I changed the logging verbosity on our Build definition to "Diagnostic".
Same as you do in VS2010 under Tools Options. Explained as a tip in this post about Silverlight obfuscation.

Logging verbosity on a Build definition
Figure: Change Logging verbosity to "Detailed"

With that I was hoping to find some issue in the msbuild output.
No anomalies found…

#2
I tried to "exclude" and "re-include" the XAP file, in order to re-trigger some VS2010 magic that happens behind the scenes.
Exclude XAP from Project
Figure: Exclude XAP from Project

Now the build is fine!! But obviously the XAP file is then not in /ClientBin anymore… which is what we are after Winking smile.
When we deploy this project we need the XAP file in /ClientBin

#3
I deleted the XAP from source control and rebuild.
Good try, no change.

#4
I deleted the XAP and re added the Silverlight application through the web application properties dialog
Re-Add Silverlight Application to the hosting web project
Figure: Re-Add Silverlight Application to the hosting web project

No luck with that one…

#5
I changed the XAP "Build action" and "Copy to Output Directory"
Changing "Build Action" and "Copy to Output Directory"
Figure: Changing "Build Action" and "Copy to Output Directory"

Setting "Build Action" to "None" will fix the build, but not include the XAP as part of the web deployment package…
Not a solution

#6
I tried to reproduce this problem with a new solution and had no luck with that. I did a "File New MVC3 app" and "File New Silverlight App" and Check In to source control.
Build server is happy and web deployment package holds the XAP file.
No repro!

 

#7
I tried to reproduce this on the existing solution.

  1. I added a new Silverlight application and hosting in the same MVC web application. FAIL!
  2. I added a new MVC3 web application and used that to host the Silverlight application. SUCCESS!

That told me that it is something with my existing MVC3 web application.

I did a "Compare" of the non-working .csproj file with the working new one.

The first difference that I found was

"Folder Include" missing on the existing web app
Figure: "Folder Include" missing on the existing web app

I added the "Folder include", but didn't fix the build on TFS

  <ItemGroup>
    <Folder Include="App_Data\" />
    <Folder Include="ClientBin\" />
    <Folder Include="Areas\Admin\Views\Shared\" />
  </ItemGroup>

 

#8
The next difference in the 2 csproj files was
The existing "broken" hosting web app was importing "Microsoft.Web.Publishing.targets"
Figure: The existing "broken" hosting web app was importing "Microsoft.Web.Publishing.targets"

 

I saw a warning with this "msbuild target" as part of the build before, but I never worried about that warning before.

image
Figure
: Error on TFS Build: Copying file ClientBin\BuildAuction.xap to obj\Release\Package\PackageTmp\ClientBin\BuildAuction.xap failed. Could not find file 'ClientBin\BuildAuction.xap'.

 

This warning comes from importing the "Microsoft.Web.Publishing.targets" in the .csproj file.

 

As part of my journey I fixed that warning by removing that Import.
Suddenly the build is green and our web deployment package holds the XAP file.
WOOOT!
image

 

I never thought a msbuild warning could break the build. But it did in this case…
The issue here is [2] in the screen above. The 2nd import of these build targets causes the build process to fail and that fails the whole build. Arrgghhh!!! So…. what should be an "Error" is a "Warning" here…

1 comment:

Phil Teare said...

jsut in case it helps anyone else, I had the problem of
"copying file obj\release\....."

file not found problem.

it was because I had some old domainservices on the server side of the project. They were excluded, but were still causing the error.

thanks,

Phil.

Post a Comment

Latest Posts

Popular Posts