views:

974

answers:

8

Does anyone know of any tools, or even good processes for deploying Web Services and Silverlight applications that rely on those, and have it be able to automatically change the web services url and port nunbers in the config files automatically?

right now I am always finding myself having to change the web service config on the server and then also have to edit the config inside the XAP. This is a pain when deploying small iterations to several servers (test, sales, demo, production, etc). I know i could write custom code, but i want to avoid that if I can.

Its especially painful forgetting to make a change and getting a call later from a tester.

Thanks

+1  A: 

Although it sounds like you have a very generic need, i.e a deployment tool, in practicallity you normally find that you are better making the tool yourself. For instance the first version may do a simple string replace on the config files that you specify.

You could then include this as post build process or as an action in an msbuild script.

There are many ways to skin a cat so for instance model your deployment scenarios via a DSL Tool modelling language that can be used to code-gen all you service configurations.

So my quick answer is I don't think there are any tools that excplictily meet your meeds.

Kinlan
A: 

Well, Thanks for the reply, at least someone did :)

My need actually is quite specific and my desire was to avoid writing my own code to do it. It doesnt even need to deploy anything. Just something that I can specify the target URL and it changes the web.config for the web service(s) and unpack the XAP, change the config in their and pack it back up. Deploying would be a bonus I guess.

I know I can write my own tool to do it, but if its already written, it saves me time. You would figure that this would be something wanted by more developers. Maybe its an opportunity to write some code for the community at large.

mattlant
A: 

I think it would be greate to come with a community based tool for this.

In the last place where I worked, we created a tool that took in the required parameters and validated them and also deployed them but it was very specific to the product we were creating.

Kinlan
+1  A: 

If you want to integrate silverlight into your build process you need to know about Chiron:

Default location: C:\Program Files (x86)\Microsoft SDKs\Silverlight\v2.0\Tools\Chiron

Chiron.exe turns the project output into a .XAP file. Using Chiron you can then integrate the xap file creation into your automated build, using a different config file for each of your environments.

Brian Leahy
A: 

Nice, I will look into it and see what I can do with it, but it sounds promising :) as multiple silverlight configs was the primary pain in the...

mattlant
pain in the asp :P
Brian Leahy
A: 

Actually there is a much easier way, and more enjoyable :)... Just use relative paths. See code sample here.

http://www.forwardvisibility.com/SilverlightCode.aspx

Thanks ~alex

A: 

This is what we use in ComponentOne (Studio for Silverlight), it's a simple method so I will share it with you:

public static Uri GetAbsoluteUri(string uriString)
{
    // convert relative into absolute
    if (!uriString.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
    {
        // remove leading slashes
        if (uriString.StartsWith("/"))
        {
            uriString = uriString.Substring(1);
        }

        // get current absolute Uri; this depends on where the app is deployed
        Uri uri = System.Windows.Browser.HtmlPage.Document.DocumentUri;
        string uriBase = uri.AbsoluteUri.Split('#')[0];

        // replace page name with relative Uri
        int ls = uriBase.LastIndexOf('/');
        uriString = uriBase.Substring(0, ls + 1) + uriString;
    }

    // return new Uri
    return new Uri(uriString, UriKind.Absolute);
}

Then, you only need to invoke it with the relative name of your web serive, to get the absolute path:

var uri = GetAbsoluteUri("myWebService.asmx")

leovernazza
A: 

For one of our projects we had a similar problem with our ServiceReferences file. Our solution was to define several ServiceReferences, with a .config for each build configuration. eg. ServiceReferences.ClientConfig.QaDeploy, ServiceReferences.ClientConfig.Debug, etc.

The project that generates the XAP then has a post-build event to copy the appropriate config file to the output location:

copy "$(ProjectDir)servicereferences.clientconfig.$(ConfigurationName)" "$(ProjectDir)servicereferences.clientconfig" /Y

If you have a fixed set of servers that you deploy to, this can easily be used for web.configs too.

Rich