New Posts New Posts RSS Feed: Web.config transformation
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Web.config transformation

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: Web.config transformation
    Posted: 18-Aug-2011 at 3:06pm
I was just messing around with this when I came across this post and thought I add my 2 cents.
 
The Web.config transformation files need to use the correct namespace for the ideablade section. So, if you have this in your web.config for example:
 
	<ideablade.configuration version="6.00" xmlns=http://schemas.ideablade.com/2010/IdeaBladeConfig>
		<edmKeys>
			<!-- Security EDM Key -->
			<edmKey name="Security" connection="..." />
		</edmKeys>
	</ideablade.configuration>
 
And say you want to replace the connection string in that edmKey, the transformation file would look like this:
 
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
 
 
  <ideablade.configuration version="6.00" xmlns=http://schemas.ideablade.com/2010/IdeaBladeConfig>
 
    <edmKeys>
      <edmKey name="Security" 
                 connection="..."
                 xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
 
    </edmKeys>
  </ideablade.configuration>
 
 
</configuration>
 
This transformation works when you actually build the deployment package, but IntelliSense complains about xdt:Transform and xdt:Locator not being defined. At this point it looks like a bug in IntelliSense. As I said the transformations do actually work.
 
 
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jul-2011 at 3:01pm

I found the problem, and it seems to be with the version and xmlns statements in the config file. When I remove them, and have sections that look like this, the transformation works:

 
From my Web.Config:

<ideablade.configuration>
    <objectServer serviceName="EntityService.svc" remoteBaseURL="http://www.oldserveraddress.com/" />
</ideablade.configuration>

 
From my Web.Release.Config:
 
<ideablade.configuration>
    <objectServer serviceName="EntityService.svc"
        remoteBaseURL=http://www.newserveraddress.com/
        xdt:Transform="SetAttributes()" xdt:Locator="Match(serviceName)"/>
</ideablade.configuration>

 
We'll open a defect to try to determine why the transformation won't work when the xmlns is declared, but in the meanwhile, this seems to be the way to do it.


Edited by robertg - 07-Jul-2011 at 3:04pm
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jul-2011 at 12:21pm
Oh, I see! I'm reading the MSDN documentation on this right now, and it turns out that the Locator is optional anyway (who knew?), so I think we can simplify things by leaving it out. Also, it looks like since you just want to replace one attribute, we probably want to use the appropriate declaration, rather than trying to replace the entire object.
 
So, I think we could try something like this:
 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <ideablade.configuration>
        <objectServer 
            remoteBaseURL="http://www.newserveraddress.com/"
            xdt:Transform="SetAttributes(remoteBaseUrl)">
            />
    </ideablade.configuration>
</configuration>
 
That way, we should be specifying that we want to transform the remoteBaseUrl property of ideablade.configuration.objectserver, and leaving everything else as it is.
 
 
Edit: Testing, and this doesn't work as expected. I'm mucking with it now and will post when it does work.


Edited by robertg - 07-Jul-2011 at 12:35pm
Back to Top
scottarlp View Drop Down
Newbie
Newbie


Joined: 07-Apr-2011
Posts: 26
Post Options Post Options   Quote scottarlp Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jul-2011 at 11:49am
Yes, sorry, when I was trying to copy/paste and protect the innocent, I accidently left that out of my example config. I'm kind of amazed that given VS2010 being out for a while and this built in studio feature being a god send for deployment that IB hasn't shown something about it somewhere. I'm no pro on all the XML tag definitions, so I'm not sure what to even google for IB's custom XML section and how it interfaces with another section (the transformation).
 
 
Back to Top
robertg View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Mar-2011
Location: California
Posts: 87
Post Options Post Options   Quote robertg Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jul-2011 at 11:41am
I'm no expert in this, but doesn't your locator declaration  need to be something like xdt:Locator="Match(serviceName)" />?
Back to Top
scottarlp View Drop Down
Newbie
Newbie


Joined: 07-Apr-2011
Posts: 26
Post Options Post Options   Quote scottarlp Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jun-2011 at 1:23pm
Does anyone have an example of the transformation of the web.config for the objectServer? I can transform elements of the config except for the IdeaBlade section. It has something to do with the custom section name, but I can't figure out a syntax to make it work. The xdt: elements are unknown within the ideablade section.
 
Example web.config (shortened). Here's the original.

<configuration>
<section name="ideablade.configuration" type="IdeaBlade.Core.Configuration.IdeaBladeSection, IdeaBlade.Core" />
</configSections>

<ideablade.configuration version="6.00" xmlns="http://schemas.ideablade.com/2010/IdeaBladeConfig">
<objectServer serviceName="EntityService.svc" remoteBaseURL="http://localhost" serverPort="80">
<clientSettings isDistributed="true" />
</objectServer>
</ideablade.configuration>

</configuration>

Then I want to do a transformation basically to change the remoteBaseURL when I publish.

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<configSections>
<section name="ideablade.configuration" type="IdeaBlade.Core.Configuration.IdeaBladeSection, IdeaBlade.Core"/>
</configSections>

<ideablade.configuration version="6.00" xmlns="http://schemas.ideablade.com/2010/IdeaBladeConfig">
<objectServer serviceName="EntityService.svc" remoteBaseURL="http://server" serverPort="80"
xdt:Transform="Replace" xdt:"Match(serviceName)">
<clientSettings isDistributed="true" />
</objectServer>
</ideablade.configuration>

</configuration>

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down