Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:53:44+00:00 2026-06-03T19:53:44+00:00

Currently my web.config looks something like this: <configuration> <connectionStrings configSource=connectionstrings.config/> </configuration> When generating a

  • 0

Currently my web.config looks something like this:

<configuration>
  <connectionStrings configSource="connectionstrings.config"/>
</configuration>

When generating a deployment package (Msbuild.exe + target=Package) it does not ‘magically’ parameterize my connectionstrings to the parameters.xml file for substitution on deployment.

When i inline my connectionstrings everything is fine and parameters are generated for my connectionstrings..

So:

How can I copy the contents of connectionstrings.config as replacement of my <… configsource=”xxx”/> on deployment trough a web.config transformation?

EDIT:
I have accepted the answer of Sayed Ibrahim because the ‘default’ behaviour is really nice (automatic parameterization of connectionstrings in web.config) But in the end its better to specify exactly which stuff needs to be parameterized (either via {projectname}.wpp.targets or parameters.xml file).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:53:45+00:00Added an answer on June 3, 2026 at 7:53 pm

    You are kind of asking the wrong question, don’t worry about how to transform back into web.config. Instead just create parameters for the connection strings in the file where they should be. I just blogged this at http://sedodream.com/2012/05/13/VSWebPublishHowToParameterizeConnectionStringsOutsideOfWebconfig.aspx. I’ve also pasted the content below for you.

    If you have used the Visual Studio web publish in either VS 2010 or VS 11 to create Web Deploy packages then you probably know that we parameterize connection strings in web.config automatically. In case you are not familiar with Web Deploy parameters, they are a way to declare that you want to easily be able to update a value of something when publishing the package later on. Connection strings are good examples of something which typically needs to be updated during publish.

    As I previously stated if you create a Web Deploy package in Visual Studio we will automatically create Web Deploy parameters for all your connection strings in web.config. Earlier today I saw a question on StackOverflow asking how to parameterize connection strings in non-web.config files (question actually asked something else, but I think this is what he’s really wanting). I created a sample showing how to do this. Below is what the connectionStrings element looks like in web.config.

    <connectionStrings configSource="connectionStrings.config" />
    

    And here is connectionStrings.config

    <connectionStrings>
      <clear/>
      <add name="ApplicationServices"
           connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
           providerName="System.Data.SqlClient" />
      <add name="OtherConnectionString"
           connectionString="data source=.\SQLExpress;Integrated Security=SSPI;Initial Catalog=foo"
           providerName="System.Data.SqlClient"/>
    </connectionStrings>
    

    In order to parameterize these connection strings you will have to extend the Web Publish Pipeline. To do that create a file named {project-name}.wpp.targets in the root of the project in which you are working (for VS 11 projects you can place all this directly inside of the .pubxml files). This will be an MSBuild file which will get imported into the build/publish process. Below is the file which needs to be created.

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
      <ItemGroup>
        <!-- Here we need to declare MSDeploy parameters for connection strings in connectionStrings.config -->
        <MsDeployDeclareParameters Include="ApplicationServices-ConnectionString" >
          <Kind>XmlFile</Kind>
          <Scope>connectionStrings.config$</Scope>
          <Match>/connectionStrings/add[@name='ApplicationServices']/@connectionString</Match>
          <Description>Connection string for ApplicationServices</Description>
          <DefaultValue>data source=(localhost);Initial Catalog=AppServices</DefaultValue>
          <Tags>SqlConnectionString</Tags>
        </MsDeployDeclareParameters>
    
        <MsDeployDeclareParameters Include="OtherConnectionString-ConnectionString" >
          <Kind>XmlFile</Kind>
          <Scope>connectionStrings.config$</Scope>
          <Match>/connectionStrings/add[@name='OtherConnectionString']/@connectionString</Match>
          <Description>Connection string for OtherConnectionString</Description>
          <DefaultValue>data source=(localhost);Initial Catalog=OtherDb</DefaultValue>
          <Tags>SqlConnectionString</Tags>
        </MsDeployDeclareParameters>
      </ItemGroup>
    
    </Project>
    

    Here you can see that I am creating values for MSDeployDeclareParameters. When you package/publish this item list is used to create the MSDeploy parameters. Below is an explanation of the metadata values each contain.

    • Kind = for this case it will always be Xmlfile, learn more
    • Scope = a regular expression to the file which needs to be modified
    • Match = an XPath expression to the attribute/element to be updated
    • Description = optional description (this will show up in the IIS manager if the pkg is imported)
    • DefaultValue = optional default value for the for the parameter Tags = optional, for connection strings use SqlConnectionString

    After you create this file you will need to close/re-open VS (it caches imported .targets files). Then you can create a web deploy package. When you do so these new parameters will be declared. In my case I then imported this in the IIS manager and here is the dialog which shows up for the parameters.
    enter image description here

    As you can see the Application Path parameter is shown there as well as my custom connection string values. When I update the values in the text box and opened connectionStrings.config on my web server they were the values I entered in the dialog box.

    FYI I have uploaded this sample to my github account at ParameterizeConStringConfig.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My build path in Eclipse looks like this: ProjectName -- WEB-INF -- classes --
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
We are currently calling web services on our application server through our web server
I currently have a web site where users can select a custom theme. After
I currently developed a web site that my user must login to web site.
I'm currently maintaining some web server software and I need to perform a lot
I am currently developing a web service that is configured to receive SMS text
I'm currently building a web form using APEX that is losely modelled after a
I'm currently writing a web application that have about 6-12 pages. On each one
I'm currently working with web services that return objects such as a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.