Search code examples
asp-classicmsbuildweb-config-transform

MSBuild - Perform all config transforms at once - and transform other files


I have been working on a build script for a website that we have. The website is a classic asp web app with an asp.net website in a folder of the classic asp web app.

We have different versions of the global.asa that need to be substituted instead of different web configs. We are in the process of moving to a continuous integration environment so much of this still new to me. I've written a build script that performs the following tasks.

  1. Cleans the buildartifacts directory if it exists.
  2. Builds the solution file with whatever configuration is passed in. This produces output with each project in a separate folder.
  3. Copies the files into the required folder structure.
  4. Packages up the result using MSDeploy as sync.

My first problem is this ...

When I run the MSBuild task like so ...

<MSBuild Projects="$(SolutionFileName)" 
         Properties="Configuration=$(Configuration);OutDir=%(BuildArtifacts.FullPath)" />

It builds the web app but does not apply any transformations. I would have assumed that MSBuild would apply the transforms automatically. Instead I end up with all 3 config files in the output folder that contains the build. Why is this? I've done some searching here, and here and they are using a separate task to perform the transformation. IF Visual Studio can apply the transforms and Visual Studio uses MSBuild I would think that MSBuild could apply transfromations? Isn't MSBuild configuration aware? Also if I have to do it separately, can I perform all transformations at once, if there are multiple config files in multiple folders at each level of the folder structure.

My second problem is ... being a classic asp web app we can't really use config files for this part of it because ... well I'm not sure how the classic asp web app would access the config file? So we have different versions of the global.asa file that would normally get replaced manually. I suppose I could do some sort of search / copy the specific asa files that we require at that time, but is there a way to perhaps use transformations to do this task?


Solution

  • Regarding the issue of transformations ... once we sorted out deployment with msdeploy we found out that msdeploy will actually perform the transformations on deployment. It stores the transformation data in one of the xml files that get created with the package.