Search code examples
visual-studio-2015msbuildslowcheetah

Web Config being ignored


I have written a web-api service and used slow cheetah to do the transforms. All is good when I compile and publish to a server with visual studio everything is transformed in many different configurations and in many different config files (connectionStrings.config etc as well as web.config).

However, when I build with msbuild this is not the case. The vanilla web.config is used and nothing is transformed.

I have made sure I am running with the correct /p:Configuration and also tried running TransformAllFiles target specifically but again the resultant file does not take into consideration my Web.UAT.config file.

I have installed slow cheetah nuget package version 2.5.15 and the project was generated with visual studio 2015.

The reason I want to do the transform is so I can pack it up with octopus and deploy to multiple servers. At the moment I am stuck.

As an aside if I run the /t:TransformWebConfig target this does transform the file but I believe this is not slowcheetah functionality and so is not really what is required.

Steps to reproduce this issue

1) Create a web api 2 project bear bones 2) Add slow cheetah 3) Install slow cheetah add in for visual studio 2015 preview 4) add a new configuration for UAT based on release. 5) exit to command line.

issue the command msbuild /t:TransformAllFiles /p:Configuration=UAT .csproj.

note in the output you will see something similar to:

> G:\dev\c#\TestCheetah\TestCheetah>msbuild /t:TransformAllFiles
> /p:Configuration=UAT TestCheetah.csproj Microsoft (R) Build Engine
> version 14.0.25123.0 Copyright (C) Microsoft Corporation. All rights
> reserved.
> 
> Build started 17/05/2016 19:32:44. The target "_ConvertPdbFiles"
> listed in a BeforeTargets attribute at "C:\Program Files
> (x86)\MSBuild\14.0\Microsoft.Com
> mon.targets\ImportAfter\Xamarin.Common.targets (34,37)" does not exist
> in the project, and will be ignored. The target "_CollectPdbFiles"
> listed in an AfterTargets attribute at "C:\Program Files
> (x86)\MSBuild\14.0\Microsoft.Com
> mon.targets\ImportAfter\Xamarin.Common.targets (34,70)" does not exist
> in the project, and will be ignored. The target "_CollectMdbFiles"
> listed in a BeforeTargets attribute at "C:\Program Files
> (x86)\MSBuild\14.0\Microsoft.Com
> mon.targets\ImportAfter\Xamarin.Common.targets (40,38)" does not exist
> in the project, and will be ignored. The target "_CopyMdbFiles" listed
> in an AfterTargets attribute at "C:\Program Files
> (x86)\MSBuild\14.0\Microsoft.Common
> .targets\ImportAfter\Xamarin.Common.targets (40,71)" does not exist in
> the project, and will be ignored. Project
> "G:\dev\c#\TestCheetah\TestCheetah\TestCheetah.csproj" on node 1
> (TransformAllFiles target(s)). TransformAllFiles:   Copying file from
> "Web.config" to "obj\UAT\TestCheetah.csproj-sc.App.config". Done
> Building Project
> "G:\dev\c#\TestCheetah\TestCheetah\TestCheetah.csproj"
> (TransformAllFiles target(s)).
> 
> 
> Build succeeded.
>     0 Warning(s)
>     0 Error(s)

Notice that it says its transformed the web.config file but when you take a look you'll notice the debug value (the one and only transform) has not changed.


Solution

  • I worked out how to do this in the end. I realised that I could simply rename my configs after the environments in octopus and include the custom transforms in The Octopus deploy user form. Therefore, my initial approach was flawed. I still use slow cheetah for local deployments which works very well but I let octopus execute the transforms for deployed instances to test, UAT and production.

    It would appear the initial task I was trying to achieve is not possible with slow cheetah at this time.