WebAPI project doesn't seem to post transformed web.config to bin folder?

1.2k Views Asked by At

I've bene doing well with .NET config transforms. I have them in place now on a class library for data usage and a WPF app.

However, when I attempt to set them up with an ASP.NET WebAPI project, something strange seems to happen.

The config file never shows up in my bin directory, and so the web.config always shows as the pre-formed config file.

If I run MSbuild with parameters of "/t:TransformWebConfig /pConfiguration=Test" on the csproj, I see the following:

CollectWebConfigsToTransform: Found The following for Config tranformation: Areas\HelpPage\Views\Web.config, Web.config, Views\Web.config, bin\Web.config PreTransformWebConfig: Skip copying Web.config to obj\Test\TransformWebConfig\original\Web.config, File obj\Test\TransformWebConfig\original\Web.config is up to date Skip copying C:\Users\killesj1\Repositories\MRP Trunk\Macro Projects\VEUploader\src\app\VEUploader.WebAPI\Web.config to obj\Test\TransformWebConfig\original\bin\Web.config, File obj\Test\TransformWebConfig\original\bin\Web. config is up to date TransformWebConfigCore: Skipping target "TransformWebConfigCore" because all output files are up-to-date with respect to the input files. TransformWebConfigCore: Skipping target "TransformWebConfigCore" because all output files are up-to-date with respect to the input files. PostTransformWebConfig: Transformed Web.config using Web.Test.config into obj\Test\TransformWebConfig\transformed\Web.config. Transformed C:\Users\killesj1\Repositories\MRP Trunk\Macro Projects\VEUploader\src\app\VEUploader.WebAPI\Web.config using C:\Users\killesj1\Repositories\MRP Trunk\Macro Projects\VEUploader\src\app\VEUploader.WebAPI\Web.Test .config into obj\Test\TransformWebConfig\transformed\bin\Web.config.

It appears that the transformation is tranforming the file, but somehow it's not making its way back into the bin directory, where the old Web.config remains.

Is this normal? How might I get this to behave similarly to other web transforms?

2

There are 2 best solutions below

0
On

I had a similar problem, deploying Test projects on Appveyor that weren't being transformed, and followed the advice in the link below and now everything works nicely. I had all my projects set up to do xxx.config transforms in the [Target Name="AfterBuild"] and it worked perfectly on my local dev machine, but on pushing the code to Appveyor, the tests would fail because of untransformed files etc. Basically, move everything to the [Target Name="BeforeBuild"] and see if that helps.

MSBuild - how to force "AfterBuild" target when I do deployment?

0
On

web.config normally located in the root and is not copied to bin subfolder. To apply transforms you need to have some template web.config and transform it to root web.config. E.g. see https://stackoverflow.com/a/16239488/52277 and Use Visual Studio web.config transform for debugging