As you may have noticed that MSCRM team has released
a new version of SDK (v5.0.5) today. The SDK includes a full functioning Developer Toolkit, which, IMHO, marks a significant milestone in CRM development practice. For the first time, the CRM development community has a first-class solution template within Visual Studio. Using the solution template, we can create, develop and deploy CRM Plug-ins, custom workflows, and web resources without having to leave the Visual Studio environment. The toolkit is designed to be a set of integrated tools within Visual Studio which help improve development productivity for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online.
This blog post will walk you through some typical CRM development scenarios, which I hope can help you become familiar with the new toolkit, so that you can take full advantage of it.
Prerequisites
The Developer Toolkit requires the following components
Installation of the Toolkit
The installation package of the toolkit can be found in the SDK download package at SDK\Tools\DeveloperToolkit. Double click "CrmDeveloperTools_Installer.msi" to install the toolkit.
Note: If you happen to have a previous version of the toolkit installed, you need to uninstall it first before installing the new version.
Note: The Developer Toolkit does not support Visual Basic .NET. If you happen to be a VB.NET developer, you will have to think about switching to C#. I doubt there is any plan to release VB.NET version of the toolkit anytime soon.
Create a New CRM Solution
To create a new CRM solution using the solution template provided by the toolkit, please follow the procedures below.
- Within Visual Studio 2010, click File –> New –> Project menu.
- In the "New Project" window, navigate to "Dynamics CRM" under "Visual C#", and choose "New Visual Studio Solution Template for Dynamics CRM 2011", and enter a solution name before click "OK" button.
- You will be prompted to enter CRM server connection information as shown below. Provide the name of your CRM server, and click "Connect" button.
- Then you will need to provide authentication information in order to connect to the CRM discovery server. After you have done so, you can click "Log on" button.
- You will now be asked to choose a CRM organization and a solution that you would like to work on. After you have provided all information required, you may click "OK" button now.
- By default, the CRM solution template will create a Silverlight project, and a companion web project for you. Enter the Silverlight web project name and click "OK" button to continue.
Note: You may not necessarily need Silverlight project in your CRM solution, but you should simply provide a Silverlight web project name in order to make the solution template wizard happy so that it can finish its own job. You can later delete the Silverlight projects if you don't actually need them.
Note: If you don't currently have Silverlight Developer toolkit installed on your computer, you will be prompted the following window.
- If everything goes fine, you will see a screen of Visual Studio as shown below. Notice that the wizard has created a Visual Studio solution which consists of a few projects, including:
Project | Role in Solution |
CrmPackage | The manifest project that that contains all assets to be deployed to Microsoft Dynamics CRM, combined with their deployment settings
Note: You should never delete this project in your CRM solution. |
Plugins | The Plugins project contains a base class named Plugin. All plug-in classes generated through the Create Plug-in option of the CRM Explorer will derive from this class. This class simplifies some of the plumbing code that's required by many plug-ins. |
SilverlightApplication | A sample Silverlight project that can be used as the starting point to develop your Silverlight web resource. |
SilverlightApplication.Web | A companion web project that host the above Silverlight project, and can be used to test the Silverlight project. |
Workflow | The Workflow project provides support for implementing custom workflow activities to be used for your on-premises Microsoft Dynamics CRM instance.
Note: Microsoft Dynamics CRM Online does not currently support Custom workflow libraries, so you may delete this project if you are working for Microsoft Dynamics CRM Online. |
Note: In the above screen, you can see a new window called "CRM Explorer", which I will explain in details next.
- Once the CRM solution has been created, the first thing you should do is to sign both your Plugins and Workflow projects with a strong name key file. You may sign your projects with a new key file or an existing one if you already have.
Use of "CRM Explorer" Window
CRM Explorer is a very useful window that's designed to help you navigate through any customizable components on your CRM server in an organized fashion.
As shown above, CRM Explorer presents you a tree window that you can use mouse click to navigate through the solution components that you are interested in. The following is a screen that shows how it looks like when it has been expanded (I truncated some entities in the screen to make it concise).
In addition to the navigation features, CRM Explorer allows you to open the CRM solution component in Visual Studio browser when you double click the item. The following screen shows how it looks like when you double click a CRM entity (Account entity in this case) in the explorer.
Another great feature offered by CRM Explorer is, you can perform certain tasks by using context menu commands when you right-click on a specific item. The following is a list of some typical scenarios that you would use the right click commands in CRM Explorer.
- Generate CRM Service Proxy Classes
Context | Entities |
Command | Generate Wrapper |
Description | Executes CrmSvcUtil.exe to generate the strongly typed proxy classes. If you only have one plug-in project, this class will automatically be added to this project; otherwise, the Generate Entity Wrappers dialog box will allow you to choose which Project to create the classes in. |
Steps |
- Right click on "Entities" node in CRM Explorer window
- Choose which project that you want the proxy classes to reside in
- Wait until it finishes generating the proxy classes, this could take a few minutes depending on the complexity of your customizations and your hardware configuration.
- The following is a screen of the generated code.
|
- Create Plugin for CRM entities
Context | Entities –> Specific Entity |
Command | Create Plugin |
Description | Opens the Create Plug-in dialog with the Primary Entity set to the selected entity. |
Steps |
- Right click a specific entity that you would like to create a plug-in, and choose "Create Plug-in" from the command menu
- Specify the details of the CRM Plugin
- Once the plugin code has been generated, you can see that the new plugin class inherits from the base Plugin class
|
- Add Web Resource items from CRM Server to the packaging project
Context | Web Resources or Web Resources -> Web Resource Type or
Web Resources -> Web Resource Type –> Specific Web Resource |
Command | Add to packaging project |
Description | Add selected web resources from the CRM organization to the CrmPackage project. |
Steps |
- Right click specific web resource item, a web resource type, or the Web Resources folder, and choose "Add to packaging project" from the command menu
- You should be able to see the selected web resources added to your CrmPackage project, from there you can work with the CRM Web Resources just like any other source code files.
|
- Add, Edit, Delete Plugin
Context | Plug-in Assemblies -> Specific Assembly or
Plug-in Assemblies -> Specific Assembly -> Specific Plugin |
Command | Add Plugin Edit Plugin Delete Plugin |
Description | Add, edit or delete CRM plugins.
|
- Add, Edit, Delete Plugin Steps
Context | Plug-in Assemblies -> Specific Assembly -> Specific Plugin or
Plug-in Assemblies -> Specific Assembly -> Specific Plugin -> Specific Step |
Command |
Add Step
Edit Step
Delete Step
|
Description | Add, edit or delete CRM plugin steps.
|
Use of "CrmPackage" Project in "Solution Explorer" Window
CrmPackage project is a specially engineered Visual Studio project template designed to manage all CRM solution components within a single place.
- Manage CRM Web Resource Metadata Attributes CRM Web Resource has certain metadata attributes associated, which dictate how the web resource items can be accessed and managed in CRM system. To change a web resource item's metadata attributes, you can click any particular web resource item in Solution Explorer window to open its Properties window, where you can change or update any properties as necessary.
- Manage Silverlight Web Resource Metadata Attributes Silverlight web resource is a special web resource type which is added to CrmPackage project through project reference. In order to change Silverlight web resource's metadata attributes, you need to expand CrmPackage project's References node, and click on the particular reference item, so that you can change or update any metadata attributes in Properties window as needed.
Note: The above two approaches are particularly useful if you have any source code files that are not currently managed by CRM Server yet, but you want to publish them to CRM Server, in which case, you can use Visual Studio's Add Existing Items command to add them to CrmPackage project, then you would provide necessary metadata attributes before you can actually deploy them to CRM server.
Publish Changes to CRM Server
After you have done all the good hard work on your CRM solution, you are ready to publish your changes back to CRM Server. The CRM Solution template has made this significantly easy, you can right-click the CrmPackage project, and choose "Deploy" from the command menu, all the changes will be published to CRM Server after all referenced projects have been successfully compiled.
Note: You need to make sure that you have signed all plugin and workflow projects in order for Visual Studio to be able to publish them to CRM Server.
I have tried to cover some most common development scenarios using the toolkit in this blog post, but I am sure that there are many other things that I haven't covered, which you can explorer by reading the user guide document that you can find from the SDK.
Note that the toolkit is currently a beta version. I have encountered a few minor issues when using it. Overall, it's a great productivity tool for CRM development. Great job by the CRM team.
Please let me know if there are any errors or typos in this post.
Hope this helps. Cheers!