Visual Studio 2010 can apply Debug or Release transformations to Web.config, but what about the Azure settings?

前端 未结 5 1224
甜味超标
甜味超标 2020-12-20 00:55

Do I have to manually edit the Azure connection strings myself to switch between production and development, or is there something comparable to the Transformation Visual St

5条回答
  •  清酒与你
    2020-12-20 01:28

    To add to what Brent has said. I use a special small configuration-only (Config) project that contains a folder for every deployment type - inside each folder there is a collection of .config and .cscfg files that are tailored toward a specific deployment (a few partial .config files too). During every compile via Pre-Build event step, Visual Studio copies the files from the correct folder into the root folder of that Config project.
    This is the command I use in the Pre-Build Event Command Line:

    xcopy /Y "$(ProjectDir)$(ConfigurationName)\*.config" "$(ProjectDir)"
    xcopy /Y "$(ProjectDir)$(ConfigurationName)\*.cscfg" "$(ProjectDir)"
    

    Every other project in the solution links to the configuration files from the root folder of the Config project.

    I also use config transformations as well, for Production vs. Non-production environments. Everything non-Production (local development environment, Azure-QA development environment) has a lot of debug and tracing built in - errors are returned completely to the clients/etc. Production environment has that locked down.

    Edit: wrote a blog about this finally: http://www.paraleap.com/blog/post/Managing-environments-in-a-distributed-Azure-or-other-cloud-based-NET-solution.aspx

    As Brent pointed out, it is not a good idea to have Staging area to be a full-blown Testing site. It is more geared toward a quick smoke test as well as a great way to deploy a new package into Azure without taking your main site down. (IP swap between Production and Deployment usually does not cause any issues to users)

    Hope this helps

提交回复
热议问题