Tuesday, May 18, 2010

Applying XDT magic to App.Config

For several weeks now people have been asking to be able to use the XML Document Transform (XDT) with App.Config files similar to what is available with Web.Config files in VS 2010…

In all honesty there is no official/supported  implementation of XDT for any other project type than Web Application Projects but the good news is that the basis of Web.Config Transformation resides in Web Publishing Pipeline (WPP) which are set of extensible tasks and targets hooked up to provide a great deployment story for Web Applications…

Today, Ming (our senior dev on Visual Studio) and I decided to get together to give some love to App.Config file too… The below implementation is a crude way of getting XDT working into other project types within VS 2010… In a way, I would say it is a big solution for a smaller problem but the idea here is to get people unblocked and show the kind of things that WPP is capable of doing… 

If by now everything is sounding foreign then please check out the articles:

  • Web.Config Transformation
  • VS 2010 Snippets for Web.Config Transformations
  • Web.Config Transforms (XDTs) for any XML files in your web projects

    Goals

    • Being able to use XDT syntax for App.Config files similar to what you can use with Web.Debug.Config and Web.Release.Config…
    • Being able to use this in an automated fashion in build environments like Team Build…
    • Reduce the concept count and make it as simple as possible (without digging deep into optimization & performance)…

    Step by Step Instructions

    The example I am using below should be hopefully super simple that you can follow along without any prep work… All you need is VS 2010 which has “Visual Web Developer” components installed…

    Step 1 Create a new Windows Forms Application in VS 2010

    Step 2 Add App.Config file to the project…

    Add simple test settings to App.Config file as shown below:

    <?xml version="1.0" encoding="utf-8" ?>
    <
    configuration
    >
    <
    appSettings
    >
    <
    add key="author" value="Vishal Joshi"
    />
    </
    appSettings
    >
    </
    configuration
    >



    Step 3 Add App.Debug.Config file to the project, I would recommend using the same App.Config file adding mechanism as shown below


    app.debug.config



    Step 4 Modify the content of App.Debug.Config as shown below:



    <?xml version="1.0"?>

    <!--
    For more information on using App.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889
    -->

    <
    configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
    >
    <
    appSettings
    >
    <
    add key="article" value="XDT Magic for App.Config Files" xdt:Transform="Insert"
    />
    </
    appSettings
    >
    </
    configuration
    >



    The key things to note above are:



    • There is a XDT namespace declaration which allows XDT engine to recognize the Transform/Locator syntax in the file


    • There is a new node being inserted into the config file using the syntax xdt:Transform=”Insert”



    Step 5 Save the edited files and unload the project frin VS 2010 Solution Explorer using the right click command as shown below:



    unload project



    Step 6 Edit the .csproj/.vbproj file to make App.Debug.Config file to be dependent on App.Config file as shown in the syntax below:


        <Content Include="App.config" />
    <
    Content Include="App.Debug.Config"
    >
    <
    DependentUpon>App.Config</DependentUpon
    >
    </
    Content
    >



    The key things to note above are:



    • By default the build action of App.Config and App.Debug.Config file will be “ None”… It needs to be changed to “Content”… This is a tiny pre-requisite for WPP but if you encounter any issues because of this then we can dig the work around…


    • DependentUpon node will make your App.Debug.Config appear as a node under your App.Config file similar to the way Web.Debug.Config and Web.Release.Config files appear under Web.Config file…


    • In VB Projects nested files are hidden so you might need to unhide these by clicking the icon on the solution explorer…



    Step 7 Change the ProjectConfigFileName property within your .csproj/.vbproj file



    WPP has an inbuilt property called ProjectConfigFileName which is by default set to Web.Config, we need to change this to app.Config which will allow projects like WinForm project not expect web.config files to transform… You can add this property right under ProjectGuid property as shown below:



      <PropertyGroup>
    <
    Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration
    >
    <
    Platform Condition=" '$(Platform)' == '' ">x86</Platform
    >
    <
    ProductVersion>8.0.30703</ProductVersion
    >
    <
    SchemaVersion>2.0</SchemaVersion
    >
    <
    ProjectGuid>{2D587604-866B-4675-8587-FA9728EC59D8}</ProjectGuid
    >
    <
    ProjectConfigFileName>App.Config</ProjectConfigFileName
    >



    Step 8 Hook up WPP within your WinForms project by importing the WPP targets.



    You can search for “Import” node in your project file and then simply copy below one line for WPP targets import



      <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" />



    Step 9 Add a target to copy the transformed App.Config file to your output (BIN) directory


    You can simply copy paste the below code just before your </project> node closes in the .csproj/.vbproj file



      <Target Name="PostTransformAppConfig" AfterTargets="TransformWebConfig">
    <
    Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\App.config')"
    SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\App.config"
    DestinationFiles="$(OutputPath)\WinFormConfigTransform.exe.config"
    />
    <
    Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\App.config')"
    SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\App.config"
    DestinationFiles="$(OutputPath)\WinFormConfigTransform.vshost.exe.config"
    />
    </
    Target
    >



    The key things to note above are:



    • We hooked up the new PostTransformAppConfig target after TransformWebConfig target… The TransformWebConfig target is the native target in WPP which does any XML transform and will do the actual job of transforming App.Config as well..


    • The location at which the new App.Config file is getting copied is pretty self explanatory but do note that you do want to change “WinFormConfigTransform” to be the name of your own Project…  I just used a project called “WinFormConfigTransform” and hence the DestinationFiles path is named as such…



    Step 10 Run /T:TransformWebConfig task on your Project from MSBuild



    You need to use Visual Studio 2010 Command prompt and type in the below command



    msbuild C:\Vishal\WinFormConfigTransform.csproj /t:TransformWebConfig



    After running the above command if you now check the BIN folder of your project you should see that the Project.exe.Config file is now modified as shown below:



    image 



    NOTE: If you want the App.Config file to be Transformed after every build in your Visual Studio IDE (this will take some perf away but may not even be noticeable) then you can change Step 9 code to be as below:



    <Target Name="PostTransformAppConfig" AfterTargets="Build">
    <
    CallTarget Targets="TransformWebConfig"
    />
    <
    Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\App.config')"
    SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\App.config"
    DestinationFiles="$(OutputPath)\WinFormConfigTransform.exe.config"
    />
    <
    Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\App.config')"
    SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\App.config"
    DestinationFiles="$(OutputPath)\WinFormConfigTransform.vshost.exe.config"
    />
    </
    Target
    >


    The only key difference above is that I made the new target to be called after “Build” and in the new target I made a call to “TransformWebConfig” target to ensure the transform happens before we try to copy the transformed app.config file to their final location…


    With the above change now when you build in IDE then the new transformed App.Config will be copied to your output directory…



    With the above 10 steps you should now be able to Transform your App.config just like the way you do Web.Config files in VS 2010



    -Vishal



    PS:  Whenever you make changes to your project file (like above) you make your project susceptible to data loss during upgrade to future versions of VS as next versions of VS will not know all the fancy code you put in the files, but such risks are part of the game to get all the fancy toys working :-)


  • Labels: , , , , ,

    48 Comments:

    Anonymous toebens said...

    hi,
    first of all: i did post a similar comment - twice - on another blog post of you but it was never approved. hope this one will be...

    we have a web.config that is making use of various other .config files that are referenced within the web.config itself, so we can separate various configurations for various staging/production systems more easy. now we would like to use XDT for these.

    for example our web.config currently contains nodes like:

    <connectionStrings configSource="connectionStrings.config" />
    <roleManager configSource="roleManager.config"/>

    and so on. we have several configurations splitted to various files (customErrors.config, smtp.config, roleManager.config myCustom.config, anotherCustom.config and more).
    sure there are also several of these files connectionStrings.config.XXXX for staging, production, development and test systems (where XXXX stand for these build configs).

    our post build scripts currently copies the correct files to the output dir and removes the .XXXX part.

    but now, as there is XDT, we would like to use XDT.
    but we would like to keep the various configurations separated in its own files, too (i.e. configurationStrings.config, smtp.config and so on).

    can you please make XDT more "generic" so it can be used with other .config files, too? (not only on web.config and app.config!?

    thanks, toebens

    p.s. i know that XDT uses the format web[.BuildConfig].config and our files currently use web.config[.BuildConfig]. it should NOT be a problem for us to change this format!

    May 19, 2010 3:44 AM  
    Anonymous toebens said...

    why do you NOT approve ANY of my comments i typed in various blog posts???

    May 20, 2010 3:36 AM  
    Blogger Vishal R Joshi said...

    Toebens,
    I did not approve comments coz I was silly :-) Honestly, I did not realize that I had accidentally set my blog to not auto approve comments and now I have several hundreds of comments to weed through... I appreciate your patience while I look through them all...
    thanks
    Vishal

    May 23, 2010 11:31 PM  
    Anonymous Anonymous said...

    from your PS "but such risks are part of the game to get all the fancy toys working"

    ..but they shouldn't be - why would transforms not have been properly implemented and SUPPORTED in all project types for VS 2010 ? This seems like a huge over site; we shouldn't have to resort to these kinds of hacks

    May 26, 2010 12:10 PM  
    Anonymous Anonymous said...

    thanks for posting this though - works great!

    May 26, 2010 12:49 PM  
    Blogger Vishal R Joshi said...

    XDT is a brand new technology and we had to try it out properly before we could reach out to everyone within Visual Studio and start asking to support XDT in eveyr project... We heard about Web.Config problems nearly every day so we first got that working and implemented in a very extensible way... By the time it was tried, tested and golden we ran out of runway to get it into every other project...
    In a way if you folks love it then let us know then it will probably make sense to push for porting it into other project types too...

    May 26, 2010 8:20 PM  
    Anonymous Anonymous said...

    thanks for the background info - that's totally understandable

    web.config transforms are a great idea! please, please push to have them implemented accross the board for VS v.Next!

    May 27, 2010 5:42 AM  
    Anonymous Anonymous said...

    The app.config transformation works great in WinForms project but it doesn't with ClickOnce. The app.congif and other configuration files that are used for transformation are copied to publish directory. The app.config files has same name and the projectname.exe.config file is not created. It's because the config files are marked as "Content" type. Can we have a solution that forks with ClickOnce also?

    Thank you in advance.

    May 31, 2010 5:25 AM  
    Anonymous Jaans said...

    Created a MS Connect suggestion for them to add it. Please vote if you want it to.

    https://connect.microsoft.com/VisualStudio/feedback/details/564414

    May 31, 2010 6:27 PM  
    Anonymous Anonymous said...

    Thanks a lot for posting. I have applied the magic to a Windows Form project and it works. I also have a installer project that takes the output of the Windows Form project for installation package.

    App.Config.xml is copied into the installation package, not the transformed one.

    Any suggestion or solution? Thank you.

    June 3, 2010 5:02 PM  
    Anonymous Anonymous said...

    How could someone ever possibly assume that transformable configurations is a feature that is desirable in web projects only???

    June 11, 2010 6:10 AM  
    OpenID jrodman said...

    Just to let you know, I could not get this to work on an x64 machine until I changed the import statement to this:

    Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"

    July 14, 2010 7:27 AM  
    OpenID jrodman said...

    After some wrangling I could not get this to work until I added a reference to system.web, just FYI.

    July 14, 2010 1:20 PM  
    Blogger Arni said...

    Intead of writing the application name manually ("WinFormConfigTransform" in the example), you could use "$(AssemblyName)".

    July 21, 2010 3:45 AM  
    OpenID outcoldman said...

    Write little tool, which can be executed from cmd for any files http://ctt.codeplex.com/ for XDT Transformation.
    So now you can set Post Build Event for running this tool.

    August 26, 2010 1:14 PM  
    Blogger Randy Magruder said...

    I'm trying to do this with a Unit Test project and I just can't seem to make it work. I've quadruple checked the steps, changed EXE to DLL where appropriate, etc. I can make a transform happen from MSBuild, but not from within the IDE, even with your steps. Is there any reason this wouldn't work in a project of type class library (Unit Test) with an app.config?

    September 3, 2010 12:48 PM  
    Anonymous Anonymous said...

    1) can you please advise if XDT will be available on "external"/separated .config files that are referenced by the web.config itself via "configSource" attribute (like described in my first comment above and as seen below in xml)




    2) is it possible to completely pre-compile a web application project with the new web deployment package option (including aspx files NOT being updateable - like web deployment projects can)

    3) if your answer to 2 is "no" - is it possible to combine both0 by first running web deployment project and then creating a deployment package (with iis settings and so on) on this non-updatedable pre-compiled web?

    thanks, toebens

    September 23, 2010 6:39 AM  
    Anonymous Anonymous said...

    hello? nothing gets approved again - and please answer

    September 24, 2010 3:25 AM  
    Blogger Vishal R Joshi said...

    If your comments are stuck for whatever reasons feel free to just send me an email at Vishal.Joshi@Microsoft.com and I will try to unblock it. I would keep the comments completely unmoderated on the blog but hate to see viagra type ads in the comments :-), and they flood up so fast that it is difficult to go to each blogpost and delete them after the fact, hope you will understand.
    Thanks
    Vishal

    September 24, 2010 10:32 AM  
    Blogger Vishal R Joshi said...

    Q 1) can you please advise if XDT will be available on "external"/separated .config files that are referenced by the web.config itself via "configSource" attribute (like described in my first comment above and as seen below in xml)

    A 1) Yes they are and the way to do it is explained at http://vishaljoshi.blogspot.com/2010/05/xml-document-transforms-xdt-for-any-xml.html

    Q 2) is it possible to completely pre-compile a web application project with the new web deployment package option (including aspx files NOT being updateable - like web deployment projects can)

    A 2) Not out of the box... Custom MSBuild targets and tasks will have to be created to do this... It is on my radar but unfortunately have not been able to find time to get it done...

    3) if your answer to 2 is "no" - is it possible to combine both0 by first running web deployment project and then creating a deployment package (with iis settings and so on) on this non-updatedable pre-compiled web?

    A.3) I am not 100% sure about the IIS Settings, can you give it a try by adding WDP on top of WAP and then click "Build Deployment Package" on top of WDP... You will have to manually put properties like IncludeIisSettings=True, IncludeAppPool=True, IISUrl=http://localhost/MvcApplication1 etc from your WAP into WDP project file... I totally understand this is a pain and will try to see whether I can abstract it out in some kind of easy fashion for everybody...

    September 24, 2010 7:04 PM  
    Anonymous Anonymous said...

    Great post! It works great.

    September 29, 2010 9:55 AM  
    Anonymous Anonymous said...

    By the look of things, it's not that different from Web Deployment in VS 2010. Why Microsoft don't support it in its IDE is beyond me.

    September 29, 2010 12:19 PM  
    Anonymous Anonymous said...

    I'm having a really hard time getting this working in my build server. Anyone have any ideas? I've used the AfterTargets="Build" option.. it works locally on my machine, but not on the build server where it builds successfully but doesn't transform the app.config.

    October 15, 2010 11:58 AM  
    Anonymous Bala said...

    Same situation as the previous poster...Does someone have a solution for that?

    To add more to that: The transform does happen. However, the transformation happens only after the drop is created and pushed to the drop folder.

    October 24, 2010 7:23 PM  
    Blogger Sayed Hashimi said...

    @Bala and others with issues, can you try this other approach. Instead of importing the Microsoft.Web.Application.targets file just paste the following into your project file (immediately above closing element)







    <_TransformFile>@(AppConfigWithTargetPath->'%(Filename).$(Configuration)%(Extension)')

    October 26, 2010 2:45 PM  
    Blogger Sayed Hashimi said...

    It looks like my last comment didn't come through due to the fact that I have XML there. You guys can grab the XML from http://pastebin.com/PLHt8wPX.

    October 26, 2010 4:56 PM  
    Blogger vincent said...

    I have a quick question on how to integrate it with Visual Studio Setup Project. Its default output is pointing to App.Config as oppose to the bin/Debug/*.exe.Config. I am wondering if you have any suggestions on how to resolve it? Thank you.

    November 3, 2010 2:42 PM  
    Blogger vincent said...

    I found an alternative by doing a pre-build copy from bin/Debug/*.exe.Config to App.Config. So, never mind. Thanks.

    November 4, 2010 8:47 AM  
    Anonymous Anonymous said...

    Thank you so much for this post and others on your site, I'm only just learning about ms deploy/web deploy and must say they're really powerful tools.

    Could something similar be done for ApplicationHost.config? I'm looking for an easy way to unblock sections of .config files so that they can be overridden at the site level. I'm also looking for an easy way to add bindings to the deployed site.

    November 19, 2010 2:05 PM  
    Blogger Vishal R Joshi said...

    >>>I'm looking for an easy way to unblock sections of .config files so that they can be overridden at the site level. I'm also looking for an easy way to add bindings to the deployed site

    Hi Anonymous,
    You can include all the IIS Configuration of your site in Web Packages, you can simply do that by checking "Include IIS Settings" checkbox on Package/Publish Web tab of your Web Project properties. If you do so you will need admin rights on the server as these properties as IIS core properties which need admin rights to be modified.
    If there are certain web.config sections which are not overridable then you will have to go to IIS Manager and select the "Server" node on the left. Then you can click on "Feature Delegation" under Management section of the server properties and allow for the required overwrites (for IIS 7)
    Hope this helps.
    thanks
    Vishal

    November 21, 2010 4:08 PM  
    Anonymous Anonymous said...

    Thank you so much for your answer!!

    It does help in the sense that this is was what I feared. But I wanted to be able to run an automated script that doesn't require the administrator to manually use feature delegation. The point being that we want to get away from including screenshots of checkboxes with our installation instructions (as Scott Hanselman talked about). I'm currently experimenting with PowerShell and AppCmd to do this, but when I use appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication it doesn't seem to be reflected in the ApplicationHost.config file, which is kind of surprising and confusing.

    The thing is, including IIS Settings is a great feature, except I need the settings on the production box to be different than those in our test/development environment, ie. bindings, since these things are not on the same domain. So after having imported the settings from my development IIS box, I would appreciate a way to customize the imported settings in Visual Studio. I'm sure this is something you're planning, so this is me looking forward to that.

    Again, thank you for your help, I realise this is not a support site and will get out of your hair now :-).

    November 22, 2010 6:37 AM  
    Blogger Vishal R Joshi said...

    Hi Anonymous,
    Editing appHostconfig is an Admin only task so unfortunately it will require admin rights to make those modifications.
    I understand your concern on not having IIS be the same on dev box and production. The ability to pass IIS Settings from a box which does not have IIS Configured as required is unfortunately not supported. We will be looking into that in the future.
    Thanks
    Vishal

    November 22, 2010 11:19 AM  
    Anonymous toebens said...

    i'm following along all the XDT stuff and blog posts by the team since the beginning, but haven't really used it in real projects/solutions yet. the process is too daunting. the is too much stuff to set up. (sure it isn't that much if you follow along such a tutorial-blog post for some tests, but it is annoying to tweak old/resisting projects and different project types for it to work.)

    hopefully XDT will make it in - baked in - the next VS2010 update/service pack so there is no need to "hack" it in different project types:

    @vishal:
    Q 1) can you please advise if XDT will be available on "external"/separated .config files that are referenced by the web.config itself via "configSource" attribute (like described in my first comment above and as seen below in xml)

    A 1) Yes they are and the way to do it is explained at http://vishaljoshi.blogspot.com/2010/05/xml-document-transforms-xdt-for-any-xml.html

    Comment 1:
    it would be pretty neat to right click a file in VS2010 solution explorer - for example - myxmlfiletogettransformedtoo.xml - to get XDT working with custom files too (the file extension could be various .xml, .config)

    Q 2) is it possible to completely pre-compile a web application project with the new web deployment package option (including aspx files NOT being updateable - like web deployment projects can)

    A 2) Not out of the box... Custom MSBuild targets and tasks will have to be created to do this... It is on my radar but unfortunately have not been able to find time to get it done...

    Comment 2:
    any updates on this?

    3) if your answer to 2 is "no" - is it possible to combine both0 by first running web deployment project and then creating a deployment package (with iis settings and so on) on this non-updatedable pre-compiled web?

    A.3) I am not 100% sure about the IIS Settings, can you give it a try by adding WDP on top of WAP and then click "Build Deployment Package" on top of WDP... You will have to manually put properties like IncludeIisSettings=True, IncludeAppPool=True, IISUrl=http://localhost/MvcApplication1 etc from your WAP into WDP project file... I totally understand this is a pain and will try to see whether I can abstract it out in some kind of easy fashion for everybody...

    comment 3:
    i could not get this working :(

    November 23, 2010 8:17 AM  
    Anonymous Anonymous said...

    Thanks! Great post and just what I needed for my Azure project.

    December 13, 2010 2:03 PM  
    Anonymous Oleg Sych said...

    Here is a solution that works with the ClickOnce publishing process. You need to override the AfterCompile target and AppConfigWithTargetPath item list.

    December 27, 2010 2:02 PM  
    Anonymous asian swingers said...

    This is nice tutorial man.Can you arrange coding part in some text part so that we reader can download for our use and test.

    January 2, 2011 7:35 AM  
    Blogger benn said...

    Very nice, thanks for the post. It worked great for me until I installed the VS 2010 SP1 beta, then I started getting this build error: 'The target "_CopyBinDeployableAssemblies" does not exist in the project.'

    Then I saw jrodman's post above (I'm also running x64) and changed my Import statement to "$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" After that, it worked great.

    February 16, 2011 8:54 PM  
    Anonymous Anonymous said...

    How to writting app.config use Visual Studio 2010

    February 23, 2011 6:19 AM  
    Blogger Vishal R Joshi said...

    toebens, Re: Pre-Compile merge, unfortunately WDP is only straight forward way right now but we will work on improving this story for the next release.

    Can you send me an email at Vishal.Joshi@Microsoft.com on what went wrong with trying to create a package from WDP. I will connect you with the team.
    Thanks
    Vishal

    April 27, 2011 12:45 PM  
    Anonymous Anonymous said...

    For anyone who has issues getting this code sample to work against Team Build (on a TFS Build Server) try modifying the DestinationFiles property of the Copy task. Use the $(OutDir) instead of $(OutputPath). The latter was not pointing to the right place on my build server and as a result the App.Config was not being included in the build output.

    May 3, 2011 10:05 AM  
    Blogger RoyalSampler said...

    For anyone who has issues getting this code sample to work against Team Build (on a TFS Build Server) try modifying the DestinationFiles property of the Copy task. Use the $(OutDir) instead of $(OutputPath). The latter was not pointing to the right place on my build server and as a result the App.Config was not being included in the build output.

    May 3, 2011 10:06 AM  
    Anonymous Anonymous said...

    hey vishal,

    unfortunately once again i was looking for a better way to precompile our web application project PLUS this in combination with config transformation and deployment and came along here again.

    i just saw your last comment and to answer your question what went wrong: its been a long time ago and i can not remember what was wrong. it didn't work + it was too complicated.

    i hope you guys will come up with a nice update on webdeploy, config transformation + precompilation very soon.

    we are still stuck on WDP, copying over the precompiled web to live server via FTP + manually updating the live server's web.config :( thats really annoying

    maybe you come up with some easier solution for this one too: http://vishaljoshi.blogspot.com/2010/05/xml-document-transforms-xdt-for-any-xml.html
    it is way too complicated to do all that stuff manually - hacking in project files.

    regards, toebens

    June 10, 2011 4:55 AM  
    Blogger Vishal R Joshi said...

    Toebens,
    sorry that you are facing the problem. I hear your pain, we will try to see what we can do.
    Thanks
    Vishal

    June 10, 2011 12:01 PM  
    Blogger Vishal R Joshi said...

    Btw, Toebens,
    WDP today does support Web.config transformation so you can actually add web.config transforms and they will happen when you use WDP as well.
    If you would like to know more about it please send me an email at Vishal.Joshi@Microsoft.com
    thanks
    Vishal

    June 10, 2011 4:22 PM  
    Blogger Uniqueculture said...

    Worked like a charm. Thanks.

    For Step 9 variable $(AssemblyName) can be used instead of hard-coded "WinFormConfigTransform" string.

    August 16, 2011 1:18 PM  
    Anonymous Blair Garrett said...

    Very useful article. Exactly what I was looking for.

    August 30, 2011 6:28 AM  
    Blogger ASN said...

    Vishal,

    I have actually written transforms for different environments for my MVC application and they work great with MSBUILD. One of the issue that we have in here is that out configs for now have some sensitive data like passwords present in it even though we are moving away from storing passwords in the web.config files. Because of this, its not so recommended for me to keep web.qa.config, web.prod.config and web.staging.config in the solution itself as all the developers will have the access to each of these files. As a part of the post build step, I want to use config transforms. Is there any utility/tool available or any facility that can help me give default web.config and transform file as the input and get environment specific transformed web.config as the output? As of now, I am not aware whether webdeploy has this capability.

    Your response will be greatly appreciated as the issue I am facing will be resolved and I will be able to use config transforms effectively for the organization needs.

    Thanks,
    Amol

    February 2, 2012 1:43 PM  
    Anonymous Sayed Ibrahim Hashimi said...

    Hi ASN, you can use the TransformXml task to take a web.config as well as a transform file to generate the final web.config. See http://sedodream.com/2010/04/26/ConfigTransformationsOutsideOfWebAppBuilds.aspx.

    February 8, 2012 3:11 PM  

    Post a Comment

    Links to this post:

    Create a Link

    << Home