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:
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'.
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.
Figure: Spiderman and Batman to the rescue
Here is my journey to fix this problem
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.
With that I was hoping to find some issue in the msbuild output.
No anomalies found…
Now the build is fine!! But obviously the XAP file is then not in /ClientBin anymore… which is what we are after .
When we deploy this project we need the XAP file in /ClientBin
I deleted the XAP from source control and rebuild.
Good try, no change.
I deleted the XAP and re added the Silverlight application through the web application properties dialog
Figure: Re-Add Silverlight Application to the hosting web project
No luck with that one…
I changed the XAP "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
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.
I tried to reproduce this on the existing solution.
- I added a new Silverlight application and hosting in the same MVC web application. FAIL!
- 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
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>
I saw a warning with this "msbuild target" as part of the build before, but I never worried about that warning before.
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.
I never thought a msbuild warning could break the build. But it did in this case…
The issue here is  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…