Friday, July 1, 2011

CRM Online :- Setting up an efficient developer environment for SilverLight resources

I've started working on a project where i am supposed to build a silverlight web resource for CRM Online and test it. The Web Resource will use CRM OData APIs to communicate with the CRM Online system and hence it can be tested only once it is hosted within an HTML page which is hosted in a CRM Online as a web Resource. 
Now here are the steps one needs to follow in order to debug this silverlight code..
1) Upload the xap file as a web resource in the CRM Online instance using the Web UI
2) Publish the xap file 
3) Navigate to the html file using the URL 
4) Attach the IE to visual studio and then debug the code by setting break points 

This makes the debugging and developing the applications very tedious since every build means that i have to upload the resource and do navigation as well... 
In order to make this process efficient here is the setup i have done on my machine 

1) Use Web Resource Upload Utility to upload the xap file on CRM Online instance. Now every time you build your solution all you need to do is to click a button to upload and publish the new xap file to CRM Online instance. 
2) In the web project you got created when you create a silverlight project add a new html page where onload of the body redirect the browser to the url where your html file is added. Here's how the code of html might look like...

Set this html page as the startup page when you debug the stuff...

And you are set... 
Now every time you change your code the debug process looks like the following
1) Build the silverlight project and use the web resource upload utility to upload the xap file 
2) Press F5 and the html page you've in your web project will redirect you to CRM Online where your xap is being hosted 

And you are set. I might work on a command line utility to build and publish the xap file on CRM Online instance if it becomes a lengthy project. But for a small POC kind of work this is much more efficient then the normal way one has to follow...

hope this helps 

No comments: