15 August 2009

Build a handy Dynamics CRM development environment

Last month, Sonoma Partners and Microsoft had an very useful article for CRM developers: Setting Up Your Development Environment, I have abstract it into Chinese version. In this post, I'd like to give my idea about how to build up a handy Dynamics CRM development environment.

The typical situation is: A CRM developer runs a Virtual PC image on his/her own PC; the virtual image is a All-In-One CRM system(Windows Server/SQL/IIS/CRM/SharePoint etc.); the Host PC has Visual Studio installed. I'm not going to discuss the mutli-developers sharing one development environment using TFS in this article.

Setup Virtual PC environment:
Microsoft Virtual PC is a free software, it has all we need to host a development environment. You may firstly install Windows Server 2003/2008 on the VPC, then install AD, DNS, IIS 6/7, SQL server 2005/2008, CRM 4, etc. Finally it's a All-In-One CRM box, I'd like to point out that:

1. It can be a Domain Controller - that's for your development only, not for production.

2. You may need 3 Network Adapters in the VPC:
a. Local only - for VPC internal use
b. Microsoft Loopback Adapter - for the communication between Host and VPC
c. Host's Physical Adapter - for the Internet access via the Host PC

The communication between Host and VPC can be used by a Physical Adapter, however think about this situation:
You have a laptop which can be used at home(via Wireless) and company(via Cable), so the IP arrange / Adapter are different.
That's the reason why we need a Microsoft Loopback Adapter in this "handy" environment(BING it: how to set up a Microsoft Loopback Adapter).

3. The VPC can be set up to the On-Premise/IFD mode, so you can develop/test both CRM deployment. You may edit Host's hosts file(e.g.: C:\WINDOWS\system32\drivers\etc\hosts) to point to the IFD URL.


Setup Visual Studio on the Host PC:
You can use Visual Studio to develop/debug CRM on the Host PC, to make it work efficiently:

1. Add user credentials to access VPC (on your Host PC(I suppose it's a Windows XP system, Vista/7 are similar), go to: Control Panel>>User Accounts>>Advanced>>Manage Passwords) , then type in VPC's Server name, User name and Password, click OK to save it.



2. To make the Remote Debug work, the runas account for Visual Studio on the Host PC and the runas account for the Visual Studio Remote Debugging Monitor(msvsmon.exe) on the VPC must use the same user name, it doesn't matter whether users are in two different domains. For example, your VPC domain name call: WIN2K3, your logon user for the VPC is Administrator; However your Host PC's logon user is: CompanyDomain\jimwang, in this case, the remote debugging will not work because it's on different users names. What you can do is, use the local Administrator account on your Host PC to run Visual Studio. E.g.: you can simply create a shortcut on your desktop, target to, e.g.: %windir%\system32\RUNAS.exe /USER:HostPCName\Administrator "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" . These two users must have the same password as well.

3. How to remote debug VPC CRM from the Host PC?
Once you completed the step1 and step2, then make sure the msvsmon.exe is running on the VPC( you can copy the file from your Host PC: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86\), the monitor will then waiting for new connections. Go back to your Host PC, set a Breakpoint in your project,
Then click "Debug">>"Attach to process...", in the Qualifier, type in the VPC's server information you created on step 1, e.g.: WIN2K3\Administrator@R2
And then attach w3wp.exe (Managed code).




4. How to deploy the plugins .dll file to VPC?
You need to deploy the .dll file to the VPC's file system in order to Remote Debug(see SDK for more information), the folder is, e.g.: C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly\
You may share the folder and give permission to everyone with full control, then in the Visual Studio, set up the project output path to the shared folder, e.g.: \\R2\assembly\
Now, you may have the experience that, every time you deploy/debug the project, you have to run a IISRESET on the VPC to release the previous .dll file.
I write a Windows PowerShell script to help you do the hard work, your may save it as RecycleCRMAppPool.ps1, then in Visual Studio, make it as the Pre-build event command line of the project. The script will recycle the CRMAppPool before deploy the .dll file.


$server="R2";

$co = new-object System.Management.ConnectionOptions;
$co.Authentication=[System.Management.AuthenticationLevel]::PacketPrivacy;
$co.EnablePrivileges=$true;

$wmi = [WmiSearcher] "Select * From IIsApplicationPool";
$wmi.Scope.Path = "\\$server\root\microsoftiisv2";
$wmi.Scope.Options=$co;

foreach($crmpool in $wmi.Get())
{
if($crmpool.name -eq "W3SVC/AppPools/CRMAppPool")
{
$crmpool.recycle();
}
}




5. You may also use Microsoft Dynamics CRM Develop Toolkit Visual Studio add-on to develop any plugin/workflow assembly/jscript for your CRM project, it will reduce your development time.

12 comments:

Anonymous said...

That's a lot of code just to recycle the application pool, Jim. Try this: http://thecrmgrid.wordpress.com/2009/08/17/restarting-the-crm-application-pool/

Jim Wang said...

Thank Greg, I supposed that the Host PC doesn't have IIS installed. :)

The PowerShell does it without IIS on the Host PC.

Alberto said...
This comment has been removed by the author.
Alberto said...

Hi Jim,

Do you know about a similar tutorial or guide for setting up a CRM 3.0 Dev Env ??

We have a running MSCRM 3.0 and need to setup an isolated environment to develop and test some customizations and in the process to train new people to maintain them in the future.

We have ASP/.Net trained programmers but the initial CRM deployment was made by some other company.

We would like to start a new development setup, import current customizations and start from there our develoment. Later, when changes are aproved, deploy them to the production environment.

Ready-to-run VPC solutions we could find around there seem outdated and are set to expire last year´s end.

We suppose we´ll have to deploy a new server (perhaps on a VPC) but we´re no t sure about the impact it could have on the current setup. We´re not sure about AD, SQL Databases, Exchange and licensing issues we may encounter on the road ahead.

Is there any hint you could give us ?

Thanks a lot in advance !!

Alberto

Unknown said...

Keep up the fantastic piece of work, I read few blog posts on this web site and I believe that your site is real interesting and has lots of great information. ERP Software in Mumbai || System Software || CRM Software in Mumbai || MLM Software

Unknown said...

I really appreciate spending some time to talk about that, I believe firmly regarding this and so really enjoy understanding more about this kind of subject.This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this. CRM Software || MLM Software in Mumbai || ERP Software || System Software in Mumbai

Muddassir said...

Thanks for sharing a best informetion
CRM Development Dubai:ERP Development Dubai

Quân Đào said...

học kế toán thực hành cấp tốc
học kế toán thực hành cấp tốc
học kế toán thực hành tại cầu giấy
học kế toán thực hành tại thanh xuân
]học kế toán thực hành tại hà đông
học kế toán thực hành tại long biên
học kế toán thực hành tại long biên
học kế toán thực hành tại hải phòng
học kế toán thực hành tại bắc ninh
học kế toán thực hành tại tphcm
học kế toán thực hành tại quận 3
học kế toán thực hành tại hải phòng
học kế toán thực hành tại bắc ninh
học kế toán thực hành tại bình dương
học kế toán thực hành tại biên hòa
học kế toán thực hành tại vinh
học kế toán thực hành tại vinh
học kế toán thực hành tại huế
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại đà nẵng
học kế toán thực hành tại hải dương
học kế toán thực hành tại hưng yên
học chứng chỉ kế toán
học kế toán ở đâu tốt

Unknown said...

Dich vu ke toan ACB chuyên cung cấp dịch vụ kế toán trọn gói uy tín chuyên nghiêp giá rẻ nhất tại HCM và các tỉnh lân cận với chi phí bỏ ra từ 500.000-1.500.000đ.
Liên hệ: Dich vu ke toan , Dịch vụ kế toán.
Lầu 4, Tòa nhà Long Mã, 602 Cộng Hòa,P.13,Q.Tân Bình,HCM.
Hotline: (08) 62 97 97 97 - 0966 660 888.

kimberlykeller said...

College exams are not hard anymore! Face even the toughest tests and assignments with Test Bank For Psychology With Dsm 5 Update Plus New Mypsychlab With Pearson Etext Access Card Package 11 E 11th Edition right away!

Elizabeth Greene said...

essay writing services have the best writers in the UK. We will deliver you the highest quality. Do not compromise your degree and grades at the same time. We promise you that your information and safety are fully secured

مگنارکس said...

Visit: کوثر طب