chiccodoro
chiccodoro

Reputation: 14716

Use Continuous Integration to modify .NET project file

We have two code bases for testing and production. The only differences between these two code bases are in two files:

Maintaining two branches is a considerable effort which could be eliminated by merging the code bases into one and using a Continuous Integration (such as Hudson, e.g.) to modify the files according to the target environment.

As of VS2010, there is a very smart solution for the config files that allows us to define different config file transformations for two build configurations "Release-Test" and "Release-Prod".

However, we have some differences that are reflected in the project file (.csproj) such as:

Is there any smart way how the csproj file can be transformed based on the build configuration, or how these settings can be extracted into a config file or C# code?

Update:

I tried with conditional MSBuild properties in the csproj file as suggested by @JaredPar, but it has a couple of caveats (see my comments for details). Are there any other ways to achieve this?

Upvotes: 4

Views: 301

Answers (1)

JaredPar
JaredPar

Reputation: 754715

It sounds like you want to use a single csproj and control elements like the assembly name based on a specific build configuration. If so then you're looking for the Conditional element on MSBuild properties

<AssemblyName Condition="'$(Configuration)' == 'Release-Prod'">Foo</AssemblyName>
<AssemblyName Condition="'$(Configuration)' == 'Release-Test'">Foo-Test</AssemblyName>

Upvotes: 2

Related Questions