How to protect VB.Net project settings when merging in TFS?

191 Views Asked by At

In a simplified version of my scenario, I am developing a VB.Net app deployed using ClickOnce, with a Live branch for production code, and a Dev branch for working in.

I want to deploy each of these branches to a different location (live for release, and dev for testing), but merging either branch into the other causes the project's "Publish location" setting to be overwritten in the target branch, meaning I might accidentally publish dev code to the live location.

Is there a way to make certain project properties (in this case, publish location) "immune" from merges, so each branch keeps it's setting?

Edit: My first idea was, if there is some "config" type file that can override certain project settings, I could cloak that file so it would not get merged... but I can't find any reference to a file like that.

We use TFS for source control.

1

There are 1 best solutions below

0
On BEST ANSWER

Solved by learning how to use MSBuild Conditions.

By editing the .vbproj file and putting the properties in question into a conditional PropertyGroup, I can merge the branches back and forth freely, and depending on the directory (branch) of the .vbproj file is in, it will use one value or the other.

(To edit the xml of your project file, right-click project in Solution Explorer > Unload Project, then right-click > Edit App.vbproj.)

...
<PropertyGroup Condition ="$(MSBuildThisFileFullPath.Contains(\AppDev\App\App.vbproj))">
    <AssemblyName>AppDev</AssemblyName>
    <PublishUrl>http://server/client/AppDev/</PublishUrl>
  </PropertyGroup>
  <PropertyGroup Condition ="$(MSBuildThisFileFullPath.Contains(\AppLive\App\App.vbproj))">
    <AssemblyName>App</AssemblyName>
    <PublishUrl>http://server/client/App/</PublishUrl>
  </PropertyGroup>
...