Branding changes via build steps

Hi there, I've got an ASP.NET MVC solution that I am building with TeamCity while using Gitlab as Source control. It's been going really well but I would like to automate things further.

The project in question is used by multiple clients, all of which have slightly different wording / colours / branding. These variables are managed via web.config (both AppSettings and system.serviceModel) as well as a _settings.scss file which contains a few variables that build the majority of the project CSS styling.

I then publish each project in the solution as the artifact BRANCH.Project.zip

Currently I am just creating a branding-* branch for each client, but it's not ideal. So my question.

Is it possible for me to store values within TeamCity and then modify the web.config and _settings.scss files to reflect these values before publishing? If I have 3 different brands I would like to repeat this step 3 times.

Thanks

-Chris

 

0
7 comments

Hi Chris,

You might want to take a look at this feature:
https://confluence.jetbrains.com/display/TCD10/File+Content+Replacer

You can set the parameters in the projects/build configurations, and then apply the file content replacer as required for the specific builds

1
Avatar
Permanently deleted user

Thanks for the reply Denis, I did notice this but the part that concerned me was....

it will run before the first build step.

I effectively want to run this process 3 times to brand the application for the three clients so...

  1. TeamCity grabs latest source code
  2. NuGet / Bower does its thing
  3. Brand for client 1
  4. Build for client 1
  5. Brand for client 2
  6. Build for client 2
  7. Brand for client 3
  8. Build for client 3

I haven't looked into the Content replacer at all because of the bold part above, do you still think it's a possibility based on what I am after?

Thanks again

-Chris

0

In your situation, it will probably make sense to separate the build process into 3 different build configurations, one per client. Then configure the File Content Replacer for each one of them with the appropriate content. That would also allow to parallelize the builds for each client (if you have multiple agents). You can use a template with parameters for what is to be replaced, then configure the parameters for each build configuration, reducing to the minimum the maintenance overhead for the builds.

1
Avatar
Permanently deleted user

Oh great call. Thank you, will give that a go.

0
Avatar
Permanently deleted user

Just thought I would follow up to say that this worked perfectly and I've now got my server building 3 branded versions of the same app.

Thanks again

0
Avatar
Permanently deleted user

So. I think I spoke too soon.

It turned out that while the work directory was showing the file modifications as expected, the changes were not being transferred across when publishing the projects.

So.. I added a step to take a copy of Web.config for each project and then after the package has been published, copy the modified configs to the required directory.

 

0

Hi Chris,

the docs specify that after the build, the changes are reverted back to their initial state, but maybe I could have made it clearer here as well. It's usually expected that if you are going to want to make the changes permanent, you will either change it on your own and commit them changed to VCS, or that you will, as you did, take a step to make the changes permanent.

0

Please sign in to leave a comment.