When you execute a build of a MVC3 or MVC2 project from 2010 in Team Foundation Build 2012 you get an error of “The target ‘CleanWorkspacePackageTempDir’ does not exist in the project”.
I was working with a customer that upgraded directly from Team Foundation Server 2008 to Team Foundation Server 2012 and that wanted to take advantage of the power of Continuous Integration. However their Solutions and Projects files we upgrades from previous versions of Visual Studio and this caused an interesting issue…
Figure: The target “CleanWorkspacePackageTempDir” does not exist in the project
Applies to
- Team Foundation Build 2012
- ASP.NET MVC 2
- ASP.NET MVC 3
- ASP.NET MVC 3 Update
Findings
After some time looking into what might be missing from the build server it looks like this is more due to MvcBuildViews conflicting with Web Deploy packaging:
- Using MvcBuildViews with One-click Publish and Deployment Packages
- MVC3 project build fails because of web.config in obj folder
- Compiling MVC Views In A Build Environment
When we first installed the build server we did not add anything other than Visual Studio 2010 Ultimate to allow for building of out of the box applications. However, when we additionally needed to build and MVC3 application that is deployed to Azure we installed those tools and SDK’s using the recommended approach of using the Web Platform Installer .
Figure: Web Platform Installer install updates MVC and removes CleanWorkspacePackageTempDir
This does however also install the Web Deploy packaging process as a pre-requisite and thus we have a new problem on out build server. Why you might ask?
Well, it looks like when you wanted to precompile your Views with MVC2 and you enabled “MvcBuildViews” you also had to add a “DependsOnTargets” attribute with “CleanWorkspacePackage; CleanWorkspacePackageTempDir; CleanWebsitesTranformParametersFiles;” to make it all work.
This was fixed by an update to MVC3 that even removed the targets. Hence the error… bummer…
So it looks like the CleanWorkspacePackage, CleanWorkspacePackageTempDir and CleanWebsitesTranformParametersFiles targets have been removed from the newer versions of the web targets file.
Figure: At some point someone enabled MvcBuildViews
So at some time in the past we wanted to enable MvcBuildViews and we added the following to our Project file:
While this worked at the time, it now caused the error that we saw.
While I initially fixed the issue, see solution below, for the MVC3 Azure build that we were trying to get working, there was a nock on affect on some of the other builds.
Workaround – Uninstall to fix CleanWorkspacePackageTempDir in Team Foundation Build
You can try to uninstall the things that you added to the build server but this tends to be a red herring and the damage is almost always done when you install SDK’s. In addition you probably added those things for a reason and you probably still have that reason. Short of completely rebuilding the Build Server this almost never works…
Workaround – Use old publish targets to re-enable in Team Foundation Build
As pointed out by the customer this should really have been the default, but the Azure and MVC teams have taken the approach to implicitly upgrade to the latest targets when they become available. The do however allow you to explicitly use the older targets.
As I can find no information on this online I will fall back on Barry Schnell’s awesome investigation on the server itself to find out that the new updates created a new build target variable called “UseNewPublishTargets” that defaults to True. When this is set to true the newer version of “microsoft.web.publishing.targets” is used and the build will fail.
Figure: Add the “/p:UseNewPublishTargets=“false”” MSBuild Argument
You can however set this variable to false by adding “/p:UseNewPublishTargets=“false”” to the MSBuild Arguments in the Build Definition on Team Foundation Server.
Solution – Remove target CleanWorkspacePackageTempDir for MSBuild in Team Foundation Build
It looks like the CleanWorkspacePackage, CleanWorkspacePackageTempDir and CleanWebsitesTranformParametersFiles targets have been removed from the newer versions of the web targets file and we just need to remove them from the Project file.
Figure: So we can remove everything in the “DependsOnTargets”
So we can now use the following without the “DependsOnTargets” directive:
This should solve the problem permanently, but make sure you test your application thoroughly…
Smart Classifications
Each classification [Concepts, Categories, & Tags] was assigned using AI-powered semantic analysis and scored across relevance, depth, and alignment. Final decisions? Still human. Always traceable. Hover to see how it applies.
What to read next
TFS Build reports Licencies.licx: unable to load type
Explains how mismatched component versions in licences.licx files can cause build errors on TFS servers, and offers solutions for consistent …
Solution: Getting Silverlight to build on Team Foundation Build Services 2010
Step-by-step guide to resolving build failures when compiling Silverlight 3 projects with Team Foundation Build Services 2010, including …
TFS Error: MSB4018 The "BuildShadowTask" task failed unexpectedly
Explains the MSB4018 "BuildShadowTask" error in TFS when using Accessors in unit test projects, its cause, and how removing .accessor files …
Unable to load task handler PowerShell for task VSBuild
Explains how to resolve the "Unable to load task handler PowerShell for task VSBuild" error in TFS vNext builds, covering PowerShell …
Detecting agile theatre with real delivery signals
Why Most Companies Operating Models Fail in Dynamic Markets
A concise comparison of Predictive and Adaptive Operating Models, explaining why traditional structures fail in dynamic markets and how …
Don’t Manage Dependencies, Remove Them
Explains why dependencies are a sign of poor system design and outlines steps to eliminate them by aligning teams, clarifying ownership, and …
The Estimation Trap: How Tracking Accuracy Undermines Trust, Flow, and Value in Software Delivery
Tracking estimation accuracy in software delivery leads to mistrust, fear, and distorted behaviours. Focus on customer value, flow, and …
Flow of Value vs Flow of Work – Misnomer or Useful Shorthand?
Compares “flow of value” and “flow of work” in Kanban, explaining why only validated outcomes count as value and stressing the need for …
Why Outsourcing DevOps Fails, and How Real Engineering Excellence Starts With Your Team
Avoid DevOps vendor lock-in, discover how true engineering excellence starts with partnership, not outsourcing. Ready to transform your …
Detecting agile theatre with real delivery signals
Don’t Manage Dependencies, Remove Them
Explains why dependencies are a sign of poor system design and outlines steps to eliminate them by aligning teams, clarifying ownership, and …
The Estimation Trap: How Tracking Accuracy Undermines Trust, Flow, and Value in Software Delivery
Tracking estimation accuracy in software delivery leads to mistrust, fear, and distorted behaviours. Focus on customer value, flow, and …
Flow of Value vs Flow of Work – Misnomer or Useful Shorthand?
Compares “flow of value” and “flow of work” in Kanban, explaining why only validated outcomes count as value and stressing the need for …
Why Outsourcing DevOps Fails, and How Real Engineering Excellence Starts With Your Team
Avoid DevOps vendor lock-in, discover how true engineering excellence starts with partnership, not outsourcing. Ready to transform your …
Estimating Better in an Overloaded System Is a Poor Man’s Strategy
High work in progress (WIP) causes delays and unpredictability; improving estimates won’t help. Limiting WIP and focusing on flow is key to …