Tag Archives: Visual Studio 2012

Debugging CRM web resources without ever deploying them

UPDATE: The steps explained below don’t work with CRM 2013.  However, Scott has a blog post which shows you how to get it working again:

http://develop1.net/public/post/Fiddler2-The-tool-that-gives-you-Superpowers-Part-2.aspx

One of my last posts was sharing how I use Visual Studio to debug CRM web resources:

http://blogs.msdn.com/b/devkeydet/archive/2013/06/19/eureka-f5-debugging-of-crm-javascript-web-resources.aspx

This approach was one of those discoveries that makes us developer types get a little excited because it allows us to do something we do repeatedly in a much more efficient fashion.  I just came across another one of those EUREKA moments thanks to Scott Durow (@scottdurow) and some his promising new http://www.sparklexrm.com project. 

BTW, Scott’s the man behind Ribbon Workbench for Dynamics CRM.  It’s the best Ribbon editor out there in my opinion.  I digress…

I was reading through http://www.sparklexrm.com/s/Tutorials/SetUpNewProject.html and discovered a little gift from Scott at the end of the walkthrough.  Steps 9-14 explain how to use www.fiddler2.com to let you debug changes to web resources without ever having to deploy them to Dynamics CRM.  How?  Steps 9-14 explain it.

Combine this with my post on F5 debugging from Visual Studio and you nearly have web resource developer productivity nirvana.  I just tried combining the two approaches.  It works beautifully!  I was able to make changes to JavaScript, hit F5, debug right in Visual Studio, and repeat over and over again.  I did this all without ever having to deploy the JavaScript file to the server.  Because of it, I was able to iterate on my changes in a fraction of the time CRM developer typically spend.  Try it yourself!

@devkeydet

EUREKA: F5 debugging of CRM JavaScript web resources

Scenario:

“Internet Explorer F12 JavaScript debugger is great, but I use Visual Studio.  I want to be able to set breakpoints in my JavaScript web resources which I author in Visual Studio, then hit F5 on the keyboard or Debug->Start Debugging from the menu or the Play Button on my toolbar just like I do with all other types of development in Visual Studio.  Visual Studio should then launch the right CRM url, attach its JavaScript debugger, and my breakpoints should be hit.”

This is the #1 piece of feedback I hear from the customers/partners/ISVs with whom I work.  I’ve always told people it’s not possible.  I just realized how wrong I am.  Given that I’ve used every version Visual Studio since it was first released, I am a little embarrassed to say I just had this “A HA!” moment.  Better late than neverSmile

As I mentioned in this post, I have stopped using the Developer Toolkit for Microsoft Dynamics CRM for web resource authoring in favor of the CRM 2011 Web Resource Linker/Publisher.  Note, I still use the developer toolkit for plugin / workflow activity authoring.  As I state in the post about the web resource linker tool, since it allows you to keep all of your web resources in a standard web project in VS, you get all the benefits of web project capabilities including other addons that work with web projects.  It’s this premise which brought me to my “A HA!” moment.  Below is a video walkthrough of getting this scenario working:

 

You can install the jQuery Code Snippets from:

http://visualstudiogallery.msdn.microsoft.com/577b9c03-71fb-417b-bcbb-94b6d3d326b8

@devkeydet

TOOL HIGHLIGHT: CRM 2011 Web Resource Linker/Publisher

I’ve blogged previously about why I like the approach CRM Solution Manager uses for authoring web resources in Visual Studio.  While I think CRM Solution Manager is a fantastic tool, there are ways to get some of the benefits of it’s approach to web resource authoring with a couple other free Visual Studio addins.  The first tool is CRM 2011 Web Resource Linker/Publisher.  This tool provides the ability to map a file in a Visual Studio project to a web resource in CRM.  Because of this, I can organize my scripts in a folder structure which aligns with the relative path naming convention that’s recommended in the CRM SDK.  See http://msdn.microsoft.com/en-us/library/gg309536.aspx for more details.  In the picture below, I just started with an empty web app and added the dkdt_ structure below:

image

Then, I simply link/publish the files:

image

Here’s an example of what initial linking looks like:

image

Notice that you can also create a new web resource right from the linker dialog.  Once you’ve linked the files, you can do things like multi-select in Solution Explorer and deploy/publish just the files you care about:

image

But wait, there’s more.  Since this is just a standard web app project, I can take advantage of all the goodness that Visual Studio 2012 has to offer.  For example, I can use NuGet to add the CRM 2011 Client Side VSDoc to get JavaScript Intellisense for Xrm.Page and simply drag and drop the file from Solution Explorer to the open JavaScript file that needs Intellisense and Visual Studio takes care of adding the reference:

image

I can also take advantage of addins which are designed to work with web projects such as Web Essentials 2012.  One example is the JavaScript Minification feature:

image

…which will give me a production optimized version of my JavaScript file.  Because these are just files, I can just relink if I want to test the minified version.  To hit home the “because they are just files” point, I’ll give you another example.  I’ve grown fond of TypeScript.  There’s even an Xrm.Page TypeScript definition file.  Because TypeScript ultimately produces JavaScript files, those files can simply be linked/published.  I think you are starting to see the “it just works” pattern here.

So, for me, I’ve stopped using the Developer Toolkit for Microsoft Dynamics CRM to Create and Deploy Web Resources because many of these things I talk about don’t work with the supplied template.  Furthermore, the Developer Toolkit forces you to deploy all of your web resources every time and it doesn’t publish.  You have to do that manually.  I’ve found the approach I lay out in this post to be the most productive way of using Visual Studio to develop web resources.  However, I still use the Developer Toolkit to Create and Deploy Plug-ins and Create and Deploy Workflow Libraries.

HTH

@devkeydet

CRM, Accessibility, and 508

I’ve spent many a time having accessibility and 508 compliance discussions with customers and partners over the years working at Microsoft and focusing on various web based technologies.  In fact, it’s hard to believe I recorded this video over seven years ago:

https://channel9.msdn.com/Blogs/keydet/Creating-an-Accessible-Web-Page

As it relates to Dynamics CRM 2011, whether your overall implementation is accessible is a combination of:

  1. Whether the HTML the CRM product produces is accessible
  2. Whether your web resources are accessible
  3. Whether any custom ASP.NET, etc. pages integrated into the CRM UI (say through iFrames) are accessible

For #1, the CRM product team produces a document called a Voluntary Product Accessibility Template (VPAT).  Ben does a good job explaining the relationship to 508 compliance and VPATs here so I won’t go into it.  As Ben mentions, all of Microsoft’s VPATs are available at:

http://www.microsoft.com/government/en-us/products/section508/Pages/default.aspx

The most recent VPAT for Dynamics CRM 2011 (as of writing this) is: Microsoft Dynamics CRM December 2012 Service Update VPAT.  For #2, the CRM 2011 SDK has a section called Create Accessible Web Resources to help you.  This section is chock full of resources and links to external resources on accessibility.  What surprised me is that it doesn’t talk about Visual Studio’s built in accessibility checker which is covered in Visual Studio’s Accessibility in Visual Studio and ASP.NET documentation.  For #3, you need to similarly understand how to make sure those pages are accessible.  Visual Studio’s ASP.NET Controls and Accessibility should prove helpful.  In fact, the 7+ year old video I recorded that I link to earlier shows both the accessibility checker and general ASP.NET accessibility techniques in action.  Hopefully this post is helpful to those of you who are going to be in the business of ensuring your CRM implementation is accessible.  Here are a few other resources you will want to review which are not linked from the other resources in this post as far as I can tell:

http://webaim.org/

http://www.section508.gov/

Now that the latest CRM Online update is complete and UR12 is out, Dynamics CRM 2011 is now cross browser capable.  Therefore, you can now use the popular WAVE Toolbar Firefox addon to check accessibility of your customizations.  Yea, I know, a Microsoft guy recommending Firefox.  I don’t know of a better free tool that allows you to check accessibility of web pages without uploading html or point the tools servers at your web site.  The latter kind of validator won’t work for CRM deployments because of authentication.  Plus, you should be testing all your customizations in Firefox and Chrome anyway.

@devkeydet

Visual Studio, ALM & Dynamics CRM

UPDATE (17MAY2013): There’s now a whitepaper on the topic as well: ALM for Microsoft Dynamics CRM 2011: CRM Solution Lifecycle Management

NOTE: I’ve included related links to both Visual Studio 2010 & 2012 content.  Even thought the Developer Toolkit for Microsoft Dynamics CRM now supports Visual Studio 2012, I recognized not everyone has upgraded.  I do my best to differentiate VS2010 & VS2012 where necessary.  You can always switch to the right version of the documentation if you click the wrong link:

image

I’ve had a recurring discussion lately about using Visual Studio’s Application Lifecycle Management (ALM) tools:

http://msdn.microsoft.com/en-us/library/fda2bad5(v=vs.100).aspx (Visual Studio 2010)

http://msdn.microsoft.com/en-us/library/fda2bad5(v=vs.110).aspx (Visual Studio 2012)

…including Team Foundation Server (TFS), when developing Dynamics CRM 2011 solutions.  CRM Development is a little different than traditional software development because you write much less code than building something from scratch (in some cases no code).  However, I am a firm believer that CRM projects should be RUN just like a custom dev project.  Especially enterprise projects.  Enter Visual Studio ALM…

Many think of Visual Studio and Team Foundation Server as just for developers, but if you read through the links above, you will learn there’s much more than what you might think.  However, leveraging all of these capabilities in the context of a Dynamics CRM project isn’t really spelled out anywhere.  This post is an attempt to be a contextualized table of contents of public information to help people understand how the two worlds collide.  The 2010 version of the ALM starter page breaks Visual Studio ALM down to:

  • Plan and track your project. Enact processes and monitor their quality to help your team turn customer requirements into working software.

  • Design functionality, either on top of existing assets or from scratch, by using architectural diagrams to communicate critical information about your team’s software.

  • Write, unit test, debug, analyze, and profile your application by using tools that are integrated with the rest of the application lifecycle so that your team can understand how your progress contributes to the project. Use version control to manage your source code and other files.

  • Build your application by using an integrated build system so that your team can ensure that quality gates have been met and verify that requirements have been fulfilled in each build.

  • Test your application by running manual or automated tests, including performance and stress tests. Manage testing systematically so that your team knows the software quality on any given day.

  • Deploy into virtual environments to enable more sophisticated development and testing.

I’m going to use this as the structure of my mapping to CRM.  There’s nothing really specific to Plan and track with CRM.  However, I find it surprising how few people are using the Visual Studio planning and tracking tools (work item / bug tracking, reports, etc.) on CRM projects.  Definitely review the material to learn about how TFS can help you run your projects.  The next area where Visual Studio can really help is Write, unit test, debug, analyze, and profile.  With CRM, you “develop” with two primary tools: The CRM Web UI and Visual Studio (usually with the Developer Toolkit for Microsoft Dynamics CRM):

CRM UI to edit Visual Studio / Other to edit
Entities, Attributes, Relationships
Forms & Views
Charts, Dashboards, Basic Reports
Workflows & Dialogs
Templates
Security Roles & Field Security
HTML, JavaScript, CSS
XML / XSL
Images
Sitemap & Ribbon
Plugin & Workflow code
Companion ASP.NET code

 

In may cases, you also use community tools to do things like site map and ribbon customizations.  However, in the end, those tools ultimately modify the CRM system (usually by modifying XML files).  So the writing code part should be pretty self explanatory through the CRM SDK (online / download) and developer toolkit.  The first place where you need to sprinkle in additional CRM context/nuance is unit testing.  My posts here should help you:

How I develop and unit test CRM 2011 plugins (make sure to use Fakes instead of Moles if you are using Visual Studio 2012)

Unit testing CRM 2011 JavaScript web resources

Debugging is another place where people get a little tripped up.  There are multiple approaches to debugging both plugins and web resources.  Debug a Plug-In explains how to attach Visual Studio to the right process to debug plug-in and workflow code.  Of course this requires you to attach to the CRM Server.  In cases where you can’t, you can profile code execution on the server, save it locally and debug by replaying captured state.  See Analyze Plug-in Performance for more details.  The CRM SDK has a section on Debugging JavaScript in Microsoft Dynamics CRM.  If you are developing your CRM code using a Test Driven Development (TDD) approach with unit testing, then you might come to the same conclusion I came to in my Developing CRM 2011 customizations without a local server post.  My personal opinion is that unit testing makes the debugging process much better and improves overall developer productivity.  So what about using version control to manage your source code and other files?  Remember that most of your non-code customizations can be exported as part of CRM solution export as XML files.  I blogged about how to integrate the SolutionPackager tool from the CRM SDK into Visual Studio to source control non-code customizations to help you get started.

The SolutionPackager tool lays the foundation to enable you to build your application on a build server.  However, most people who go to the extent of using a build server also want more advanced build automation such as deploying to a test server or virtual environment.  While there’s a whitepaper called Deploying Microsoft Dynamics CRM 2011 and CRM Online Solutions from Development through Test and Production Environments which covers some of the nuances of such automation, it leaves much of the work to you to implement.  Thankfully, ADXStudio has built the Adxstudio ALM Toolkit which greatly decreases the time it will take a team to reach this level of automation.  Shan McCarthur delivered a fairly comprehensive webcast on team development that brings all the core topics together.  While the webcast is relatively ALM tool agnostic, it’s not a far leap to understand how use Visual Studio ALM tools after watching and having gone through the material in this post.

What about functional testing?  Unit testing is great and all, but not everyone is bought into TDD and unit testing.  I always tell people that unit testing doesn’t replace functional testing.  However, it usually DOES result in less bugs found during functional testing.  The Creating and Managing Tests section of the Visual Studio ALM documentation does a good job of navigating you through the different kind of functional testing it supports.  The little gem that I don’t think enough CRM projects are utilizing is Testing the User Interface with Automated UI Tests (aka Coded UI).  Dynamics CRM 2011 is one of the many Supported Configurations and Platforms for Coded UI Tests and Action Recordings.

And performance testing?  Performance testing is absolutely critical for any large scale software solution.  Not enough people do it.  The end result is usually finding issues in production when you go live.  UGH!  Performance testing can prevent lots of heartache.  The Visual Studio has tools to help you in your Testing Application Performance and Stress.  A compliment to Visual Studio is the Performance Toolkit for Microsoft Dynamics CRM 2011 which is just a set of guidance + additional tools which show you how to Visual Studio Stress Testing Tools with CRM.  Stress testing with CRM is a pretty specialized skill.  While I’ve given you pointers to the tools to do it yourself, you might want to consider the Microsoft Dynamics Benchmark offered by the Dynamics Premier Field Engineering (PFE) team at Microsoft.

@devkeydet

CRM Developer Toolkit & Visual Studio 2012

One of the things I have been getting asked about lately is “When will the Developer Toolkit for Microsoft Dynamics CRM  support Visual Studio 2012?”  It already does!  Just go download the latest version of the SDK.  You’ll find a two installers for the toolkit.  One for Visual Studio 2010 and one for Visual Studio 2012.

@devkeydet

CRM Solution Manager keeps getting better

Full disclosure, I received a free license from the authors of the tool.  However, I do believe it’s definitely worth the license fee.

I’ve blogged previously about reasons for my fondness of the www.crmsolutionmanager.com addin to Visual Studio for Dynamics CRM 2011 development.  Well they’ve recently introduced some new features that I think make it an even more compelling alternative to the Developer Toolkit for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online.

@devkeydet