Thursday, February 17, 2011

CRM 2011 - Accelerate Silverlight Webresource Development

Yes, it is hard to develop "big" Silverlight applications against the new Organization Service. One of the biggest problems, is the time consuming deployment of the xap/html files as webresources.

Microsoft delivers a nice tool for accelerating this task a little bit. It is called "webresourceutility" and you can find it in the SDK. But only the sources are available. So you have to open it in Visual Studio 2010 and rebuild it.

If you would like to extract it from the SDK-Folder (Maybe for versioning), additional folders are required because references exists in the Visual Studio Project.

Required:
  • sdk\tools --> Contains the tool
  • sdk\bin --> Contains the Microsoft XRM/SDK assemblies
  • sdk\samplecode --> References to DeviceIdManager.cs, MyOrganizationCrmSdkTypes.cs and CrmServiceHelpers.cs
If you have opened the solution, you can see the WPF Application (implemented with MVVM-Pattern). Pressing F5 should already start the application but you will run into an exception concerning missing Identity Model. You have to install Windows Identity Framework

WIF Download
I am using the Version 6.1 and it works fine, but i don`t know the difference between 6.0 and 6.1.

If you are using Windows XP, look here.

Now the tool should work.



The first step ist NOT to enter some information. Please click "NEW" before! ;)

Now enter all the stuff:
  • Name: Describes the Name of your connection. Maybe you have DEV, QS, LIVE or stuff like this.
  • Server: IP or Servername with the port if it is used
  • Organization: CRM Organization-Name
  • Username: CRM-Username
  • Domain: Domain of CRM Server
All this information will be stored in "configurations.xml".

Clicking "Connect!" will open a prompt for the password. Enter the user password and click submit.

The application switches automatically to the "Solutions" tab. Here you can select one of the solutions, currently deployed to the CRM Server. If there is no solution available, you have to create a new one. Infos about creating solutions you can find in the actual SDK.

Select your solution and click "Choose".

The application will change to the "Web Resource Packages" Tab with a empty List. Clicking "New Package" will open a new area.

Here you can enter the content of your package.

  • Package Name: A Package is the summary of webresources you would like to deploy in this step. For example if you are deploying a Silverlight application you can deploy the .HTML and the .XAP.
  • Root Path: The place where all of your webresources are stored on your local disc.
  • File Search: All files which are available in the selected root path are displayed. You can filter them, select the required and then push the "Add Files to Web Resources" button.
  • Web Resources: Here you can see the added files. Another importand part is the "Use Package Name as Web Resource namespace". If you select this, the namespace/folder will be extended with the name of the package. This can be tricky in HTML-Pages which hosts Silverlight Apps)
  • Publish all customizations after uploading web resources: The resources will always be uploaded AND deployed.
  • Save Package: Save your configuration to the "packages.xml"-File
  • Upload All: Uploads all Webresources in the "Web Resources" Area
  • Upload Selected: Uploads the selected Webresources in the "Web Resources" Area
  • Show Output: Shows the log which was created in further import processes.
Thats it. Now you can Write Code --> Build --> Click Upload --> Test. You can also use the existing code in the tool to create your own console application which is triggered in the post build event of the crm. The concept of the XML-Files is perfect for this approach.

Another Tip:
Yes security is important, but in the DEV-Team the password to the User of a DEV-Server is not that big secret. So you can remove the password promt.

  • Open the webresourceutility Solution in Visual studio
  • Navigate to ..ViewModels\MainWindowViewModel.cs
  • Jump to "InstantiateService()" Method (should be line 694)
  • Change code:

Before:


//Get the Password
string password = String.Empty;
PasswordWindow pw = new PasswordWindow();
pw.Owner = Application.Current.MainWindow;
bool? submitted = pw.ShowDialog();
if (submitted.Value) {
password = pw.GetPassword();
} else {
ErrorWindow needPassword = new ErrorWindow("You need to supply a Password and Submit. Try again.");
needPassword.Owner = Application.Current.MainWindow;
needPassword.ShowDialog();
return;
}


After:

//Get the Password

string password = "YourPassword";



cheers

No comments:

Post a Comment