Red Gate forums :: View topic - Configuration file transformations for specific machines
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
Deployment Manager
Deployment Manager forum

Configuration file transformations for specific machines

Search in Deployment Manager forum
Post new topic   Reply to topic
Jump to:  
Author Message
swinghouse



Joined: 12 Sep 2011
Posts: 99

PostPosted: Thu Jan 03, 2013 9:22 am    Post subject: Configuration file transformations for specific machines Reply with quote

Configuration file transforms work beautifully with environments in Deployment Management, but is there any support for machine specific transforms?

The scenario I'm thinking of is this:

    Machine1 and Machine2 both belong to Environment1. One or more settings need to be unique for each machine, for instance the database connection string.


What I've been trying to do is to define the connection string transform in Web.Machine1.config and Web.Machine2.config, respectively. Alas, DM doesn't seem to pick up these. (The same transform rules in environment specific config files do get processed by DM.)
Back to top
View user's profile Send private message
justin.caldicott



Joined: 20 Apr 2011
Posts: 55

PostPosted: Tue Jan 08, 2013 4:23 pm    Post subject: Reply with quote

Is it the same project that you want to configure differently between machines?

The web config transforms work only for Environments. You could try specifying the connection strings in a Deployment Manager variable, and using a powershell deployment script to apply a further transformation of the web.config. The variable could then be customised per machine as you need.

Actually, it seems nicer to work this way, as then the package does not need to know what environments you want to deploy it to, meaning you can add/change environments and configuration without needing to build a new package.

This requires a powershell script to modify the web.config as appropriate. I found an example of doing that on StackOverflow: http://stackoverflow.com/questions/11724422/powershell-writing-xml-file-disable-output-escaping

I expect later we will have more flexibility in terms of deployment steps, and that Web Config Transform step might be more configurable.

Thanks,

Justin
_________________
Justin Caldicott
Product Manager - Deployment Manager
Red Gate
Back to top
View user's profile Send private message
swinghouse



Joined: 12 Sep 2011
Posts: 99

PostPosted: Wed Jan 09, 2013 3:03 pm    Post subject: Reply with quote

Hi Justin,

Yes, you assumed correctly - same project, different machines.

I'll look closer into your suggested solution in a while. It certainly looks doable!

Thanks for the help!

/Mattias
Back to top
View user's profile Send private message
Mike Upton



Joined: 11 May 2011
Posts: 135
Location: Red Gate

PostPosted: Wed Jan 16, 2013 12:03 pm    Post subject: Reply with quote

Deployment Manager can already update certain parts of app.config and web.config files based on variable definitions. It will look for appSettings and connectionSettings whose names match deployment variable names, and replace the values with the appropriate deployment variable value, without you needing to write a Powershell script.

For example, if your web.config had the following connection string definition (example from MSDN):
Code:
<connectionStrings>
  <add name="NorthwindConnectionString"
    connectionString="Data Source=serverName;Initial Catalog=Northwind;Persist Security Info=True;User ID=userName;Password=password"
    providerName="System.Data.SqlClient"  />
</connectionStrings>

And you defined a Deployment Manager variable with the name "NorthwindConnectionString" and the value "Data Source=.;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=my_very_secure_password", the connection string in the web.config would be replaced. Because this uses a normal deployment variable, you can define different values for different Environments, Machines, or even Steps within a project.

This also works for appSettings in the app.config:
Code:
<appSettings>
  <add key="SettingName" value="TestValue" />
</appSettings>

You can replace the value on deployment by adding a deployment variable named "SettingName" with the new value.

(some documentation for this feature can be found here)
_________________
Mike Upton

Software Engineer
Red Gate Software Ltd.
Back to top
View user's profile Send private message
swinghouse



Joined: 12 Sep 2011
Posts: 99

PostPosted: Tue Jan 22, 2013 5:52 pm    Post subject: Reply with quote

Hi Mike,

Even though my question was specifically about the integration with .config transforms, it was good to read your succinct overview of the other options available in Deployment Manager.

Thanks!

/Mattias
Back to top
View user's profile Send private message
swinghouse



Joined: 12 Sep 2011
Posts: 99

PostPosted: Tue Jan 22, 2013 6:13 pm    Post subject: Reply with quote

Regarding variables, I've added a feature request at http://redgate.uservoice.com/forums/176290-deployment-manager/suggestions/3578134-allow-variables-to-control-all-sections-in-config-
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group