Running a build against multiple projects with different build arguments

怎甘沉沦 提交于 2019-12-13 00:38:08

问题


I have a series of projects that need to be compiled and published, deployed to separate directories with separate MSBuild arguments. As it stands, I have separate builds for each. For example, project 1:

MSBuild Arguments: /target:myTarget /property:PublishDir=\\1.1.1.1\PublishDir1

and project 2:

MSBuild Arguments: /target:myTarget /property:PublishDir=\\1.1.1.2\PublishDir2

However I'd like to merge them into a single build. The problem I have is that although TFS will allow me to specify multiple projects in the build, the MSBuild arguments apply to all projects. Is there a quick way I can force a distinct set of build arguments per project, or do I need to create a new build template to do this?


回答1:


I am afraid, you need new build template to pass additional arguments to the template.

But if you are trying to Publish the build output to different directory based on different Project, you can achieve it by setting up same publish profile for each project. Add publish profile for each Project with same name. you can use File system Publish Method to Publish the output to different directories for each project. Just call the Publish profile in the MsBuild Argument.

/p:DeployOnBuild=true;PublishProfile=Dev



回答2:


I suggest, that you create an MSBuild .proj file to execute the builds, i.e.:

<Project ToolsVersion="4.0" DefaultTargets="Rebuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Rebuild" >
<!--Execute proj1-->
<MSBuild Projects="Proj1.csproj" Properties="Configuration=Debug;PublishDir=\\1.1.1.2\PublishDir1;></MSBuild> 
<!--Execute proj2-->
<MSBuild Projects="Proj2.csproj" Properties="Configuration=Debug;PublishDir=\\1.1.1.2\PublishDir2;></MSBuild> 
</Target>
</Project>

Just point your tfs to this custom .proj file.



来源:https://stackoverflow.com/questions/18331869/running-a-build-against-multiple-projects-with-different-build-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!