Reputation: 11625
We've just added a dedicated test server for our Silverlight applications. We are deploying full copies of all our apps and services onto the test server. The issue we have is that we need to manually update ServiceReference.ClientConfig when we deploy, to point to the appropriate server (ie. test or live).
I'm sure this is a common issue. What is the "best practice" solution?
Upvotes: 0
Views: 377
Reputation: 2880
I am using this method:
http://www.funkymule.com/post/2010/03/08/XML-Transform-on-Silverlight-ClientConfig-Files.aspx
It is simple and works fine.
Upvotes: 3
Reputation: 38179
I usually create a Configuration folder in my SL web project, containing a ServiceReferences.ClientConfig for each location I intend to publish the application to (ServiceReferences.ClientConfig.dev, ServiceReferences.ClientConfig.test, ServiceReferences.ClientConfig.prod).
Then I create a solution configuration for each environment (dev, test, prod) and set the SL app build event to:
xcopy /R /Y $(ProjectDir)Configuration\ServiceReferences.ClientConfig.$(ConfigurationName) $(ProjectDir)ServiceReferences.ClientConfig
Before publishing, I just need to select the configuration, build and publish
Upvotes: 1
Reputation: 9290
I would programmatically change the endpoint's hostname inside your silverlight application depending on a particular parameter passed from the host page to the SL app (of course this means you will have to host your application on a different page when you deploy on the test server -or you can edit the host page "on the fly" as part of your deploy script).
For ex.: on the test page:
<param name="initParams" value="testServer=myhost.com"/>
Then in the Silverlight app you read the testServer parameter (you receive the initParams hashtable in the Application_Startup event) and programmatically set the hostname to what you received. You will need some kind of centralized factory for the remote proxy otherwise you will have to replace the hostname in several different places.
Also, I would only do this #if DEBUG (or even better define another compilation constant that will be removed before the actual deploy) so there's no risk that this will be used for any malicious goal.
Upvotes: 1