AppHarbor Environment does not seem to affect web.config transformation

亡梦爱人 提交于 2019-12-11 03:44:25

问题


According to the description, it would appear that you can change the "Environment" in the application settings to apply a different web.config transformation.

Environment

The environment name affects which configuration transformation we apply. An environment named "Release" will apply "Web.Release.config" to the "Web.config" file.

However, after doing so, it appears that it is still trying to transform using the Web.Release.config.

**C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets(182,5): error MSB3030: Could not copy the file "Web.Release.config" because it was not found.

Am I missing or misinterpreting something?

EDIT: For reference, here is the source repo: https://github.com/jrmitch120/ChallengeBoard


回答1:


Make sure you have all your config transformations in your solution marked as "Content" in the "Build Action" under the preferences in Visual Studio - recommit and should work.




回答2:


Quick Fix:

AppHarbor has its own settings which are applied during deployment. One of these settings contains the AppHarbor Connection String, the other one is an Alias which needs to match the key for the connection string inside your web.config.

If you change following "SQLSERVER_CONNECTION_STRING_ALIAS" in AppHarbor to match your connection string Key this will cause App Harbours SQL Server Connection to be applied during deployment which is probably as much as most people really want. It feels better to me that SQL Connection settings (and other deployment settings) are maintained outside of the normal webconfig transformations.

Bigger Description of some of the Issues:

As for as I can tell from an afternoon of diagnosing and trying things the following steps take place which may help explain help diagnose why things aren't behaving as expected:

  1. AppHarbor Runs the Build and Runs the Tests, (You can download the output of this from the App Harbour Site)

  2. Post Build (and in a separate folder you cannot see), the output of the Build Is Put through App Harbors own Transformation. Because this is outside of the Build the files need to exist for this to occur. Web.Release.Config must be set as a Build Action of Content otherwise this transformation step won't be able to pick this up

  3. Post Transformation an additional set of settings are applied. Connection Strings will be overwritten etc etc, see blog post below on how this works:

http://chandermani.blogspot.co.uk/2012/03/nerddinner-on-appharbor.html

In Summary there is quite alot of interplay and things that could go wrong.

  1. There is the possibility for step 3 to overwrite the transforms you were trying to do in step 2 making it look like the transforms didn't work.

  2. There is the possibility the Web.Release.Config file wasn't set as Content.

  3. Finally because this is AppHarbors Slightly customised Transformation which occurs after the build it doesn't always seem to be consistent with what happens in Visual Studio. I had a problem where I was missing a setting in web.config that was blocking a transform from occurring. There is a test tool you can use to check how the transforms will occur here: https://webconfigtransformationtester.apphb.com/

I have finally got settings being applied correctly, and the transforms being applied in my own site but it took quite a long time. I hope this answer will help somonelse



来源:https://stackoverflow.com/questions/15485377/appharbor-environment-does-not-seem-to-affect-web-config-transformation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!