开发者

How to tell MSBuild to publish many web projects into one directory?

I am running Automatic Builds with TFS 2010. In a solution I have more than one web applications which are 开发者_开发问答all located under the same root directory - e.g.:

RootDir ->

   WebApplicationProject1.csproj
   WebApplicationProject2.csproj
   ...

When I run automated build, I set the following arguments for MSBuild:

/p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;_PackageTempDir="\computer\Builds\Published" /p:SkipExtraFilesOnServer=true

However MSBuild does not preserve existing content in this folder and with each project the content in this folder is being deleted. The last project to be built is the winner.

Can I make MSBuild not to delete the content in this folder and only replace existing files?

Thanks for any information on this matter.


You do not have to create multiple build configurations. Simply define a solution that contains both projects, create a build definition for this solution and add a AfterDropBuild target that copies everything form the PublishedWebservices output subfolders to a common folder.


You need to tell MSBuild about your multiple targets

Try

<Target Name="Build" DependsOnTargets="T1, T2">
</Target>

MSBuild allows you to define a default Target and it allows you to define dependencies among your Targets. If no default is defined, then it runs the first one it finds. Using DefaultTargets you can call multiple:

<Project DefaultTargets="T1;T2">

A Target should accomplish all of one well defined step. For example a Clean target would remove all the necessary files and folders needed to clean the project. Compile would compile all the DLLs, etc.

Your targets should normally declare their own dependencies:

<Target Name="CI" DependsOnTargets="T1, T2">
</Target>

Otherwise your target should contain all the individual steps that you want to run:

<Target Name="XX">
    <CallTarget Targets="T1"/>
    <CallTarget Targets="T2"/>
</Target>

if you still face confusion, check out this link


You could build them all to separate folders and then copy all the results into the final folder. If files have the same names, it would probably be messed up, but it would be that way if you could directly build them all into one folder anyways.


This seems to be just the way Microsoft wants it. I found the same thing to be true in VS2008. Building the project would wipe out the entire folder, including .svn.

My solution is to create a post-build event to copy the files from each location into a common folder. It's not ideal, but it does work without any major hangups that I found.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜