1

TeamCity CI has a variable %system.build.number% which will be incremented in the format 1.0.%build.counter%.0. This will generate assemblies with different version number each time. I want to add this new version number in my app.config file. Whats the easiest way to do this. I have 100 projects which have app.config and mostly all use the same assemblies. Can I have a common app.config file which I can link and modify it. Well, please provide a example of how to modify the newVersion field in the binding redirect to the current build number provided by teamcity using a XmlTransform.

<?xml version="1.0" encoding="utf-8"?>
<configuration>     
  <runtime>
    <legacyUnhandledExceptionPolicy enabled="1" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">     
    <assemblyIdentity name="MyApp.Data.Model" publicKeyToken="866d4a0fa0594321" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.0.1.0" newVersion="1.0.2.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

abatishchev
  • 95,331
  • 80
  • 293
  • 426
jero2rome
  • 1,518
  • 1
  • 19
  • 38

1 Answers1

1

You can use xdt transformations. Here is a snippet of powershell function, Web.Config transforms outside of Microsoft MSBuild?

You then create meta runner (more help http://confluence.jetbrains.com/display/TCD8/Working+with+Meta-Runner) for transforming configs with XDT and use it in a build step. That's it :)

You could also create msbuild task and invoke msbuild instead of powershell function.

Community
  • 1
  • 1
Dejan Dakić
  • 2,358
  • 2
  • 23
  • 39