Andreas Reiff
Andreas Reiff

Reputation: 8404

TFS 2010 Build a solution with different paths for some projects

I have a solution that I am using for a build task of TFS 2010 (build server).

Most projects are fine to end up in the same location, only difference is some dynamically loaded plugins, which should be in a /Plugins subfolder relative to the other assemblies.

1) I have tried a few things, like modifying my DefaultTemplate.xaml, only to find out, that (since I only specified the .sln file) I cannot distinguish the output path on a per-project level. (In the workflow, there is a "For Each Project in BuildSettings.ProjectsToBuild" with a serverBuildProjectItem variable - this is only called once though with the .sln file as my project.) So this does not work to distinguish on a per-project basis.

enter image description here

2) One more thing I tried was to specify the OutputPath as found somewhere as a solution.

<OutputPath Condition=" '$(CommonOutputPath)'=='' ">../myOutDir/Plugins/</OutputPath>
<OutputPath Condition=" '$(CommonOutputPath)'!='' ">$(CommonOutputPath)Plugins\</OutputPath>

This leaves all assemblies in the same folder for the server build as well and thus does not work.

3) I started creating a post-build event to manually copy the files to the correct location, but so far failed to distinguish the server-case from the local case. (This here does not work.)

<PropertyGroup Condition=" ' $(TeamBuildConstants) ' == ' '>
<PostBuildEvent>mkdir $(SolutionDir)..\out\$(OutDir)plugins
copy $(TargetPath) $(SolutionDir)..\out\$(OutDir)plugins
</PropertyGroup>
<PropertyGroup Condition=" ' $(TeamBuildConstants) ' == '_TEAM_BUILD_ '>
echo figure out some copying for this once the condition gets hit..
<PostBuildEvent></PostBuildEvent>
</PropertyGroup>

How can I change either the project files or configure the build workflow to have this work? (Should then work locally as well as for server builds.)

What I want: Have all standard assemblies in same folder, have all plugin-projects in ./Plugins/ subfolder? (Locally, relative to project file (default?), tfs-build relative to specified drop location)

Upvotes: 1

Views: 1215

Answers (1)

drk
drk

Reputation: 865

From 2010 with the introduction of workflow based tfs builds there is strong distinction betwean them and msbuild - compile your projects and their content with msbuild, assemble the deplopyment package with workflow.

Since you state that this should run localy, meaning plugins are required for your compilation to succeed/projects to work, hence they should be handled on solution level.

There is several aproaches you can use

  • Post build events for each project - you will probably provide 2 sets of actions one for local builds others on tfs - your aproach 3, to distinguish between modes you can use(there is variations how and where you can do it this one has advantage of being editable from project properties)

Build in tfs (outside VS)

<PostBuildEvent> IF NOT "$(BuildingInsideVisualStudio)" == "true" ( YourActions ) </PostBuildEvent>

Discussion about it:BuildingInsideVisualStudio Property Value Not Working With File Reference and Project Reference Conditional

  • Add or add as links plugin files as items from relative central location in source control to Plugin folder for each project, define item build actions probably as copyifnewer/always content

Upvotes: 1

Related Questions