The new web publishing (WPP) in .NET 4.0 has a method for managing output location.
First, you need to switch to WPP while the CopyWebApplication target is running. Set the following MSBuild properties on the command line or in the MSBuild project file:
<PropertyGroup> <UseWPP_CopyWebApplication>True</UseWPP_CopyWebApplication> <PipelineDependsOnBuild>False</PipelineDependsOnBuild> </PropertyGroup>
Command line option:
/p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False
Then create a new MSBuild goals file in the same directory as your project and name it "ProjectName.wpp.targets", where "ProjectName" is the name of your project, minus the extension. In other words, if you have "MyWebsite.csproj", you need to create "MyWebsite.wpp.targets". I find that this helps add the goals file to the project. This is not required, but it simplifies editing.
In the new target file, you need to override the WebProjectOutputDir property. Do this only when CopyWebApplication is called - in other words, when "OutDir" is redirected from "OutputPath":
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WebProjectOutputDir Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)Websites\MyCustomFolderName</WebProjectOutputDir> </PropertyGroup> </Project>
What is it - you must be good. You can check it locally by setting the OutDir property. Do not forget the backslash:
msbuild MyWebsite.csproj /p:OutDir=C:\Development\WebOutputTest\
source share