Deploy your WebResources to CRM (OnPrem/Online) using VSTS/TFS

These last months, i focused myself to think of :
What would be the best Continuous integration for CRM development ?

Today, with my experience, i will try to give you a nice input of the solution I started to work on.

1. Chosen tools

This is not a big surprise here, as the article's title says...
I decided to give a try with Visual Studio Team Services(VSTS)/Team Foundation Server(TFS) (depend if you are OnPrem or Online).

Why did I decide to go this way ?

Well, with the new things coming from MS and the wishes to push more and more applications / functionalities to the Cloud, I assume, it was all decided for me as it was also matching the goal of my company.

2. What do I want to achieve exactly ?

I used to work with the CRM Developer extensions. These are really good, I have nothing to say against it. But it's need require a bit of manual steps there to publish / create files.

When I started to think about it, VS 2017 just came out and there were no CRM Developer Extension for this visual studio version at this point. So, I was a bit stuck and didn't want to open my CRM to push WebResources manually everytime.

So i thought of what we could do and my goal was roughtly to have something like :

  • Code on my laptop and commit
  • generate a build / release automatically via VSTS
  • VSTS pushes my new code to CRM and publish it.
  • And that's it !

If i want to detail a little bit but the process from : Laptop > VSTS > CRM seems really cool but how and what should you do to achive this.

3. Overview of the process with the steps inside

Here is a more details process of the overwall idea :

From this point, we will focus on what's really happening inside the 2 big steps on VSTS/TFS :

  • the blue one related to the build part
  • the green one related to the release part

The Blue step : From this point, we want to focus on :

  • How to get our latest code version from the repository
  • Create an artifact of the code/files we want from the repository

Here is the steps to configure in VSTS/TFS to achive that :
1. Get Sources : A simple task which allow you to retrieve the code from your favorite repository (git, svn, ...)

2 a. Copy files : Here we can specify which files/folders we want to keep from the repository. In my case, my project contains folders (scripts, html, css, doc) and i want to keep only "html and scripts"

2 b. Publish Artifact : During this step, VSTS will create some kind of "package" called an artifact containing only what you specified above.

The artifact can be hosted on a fileshare or directly into some databases, this depends mainly on how you want to manage your stuff and on your architecture.

The Green step:

  • How to retrieve the code from our generated artifact as seen in the blue step
  • How to actually publish it to the CRM

1. Get the artifact: In the "Artifacts" tab, you can automatically link a generated artifact from a build to the release. This will by default, when the release will run, download the content of the artifact and use it to continue the release process.

2. Powershell script to publish : Here i won't try to get credit for the script. I'm using this script with a little bit of adjustment and this library to be able the use the sdk. Additionnally to the task configuration, there are some variables configuration which are used in the script. This way you have a generic script which retrieve the variables based on the environment (CRM account, CRM password, Url to CRM environment ...)

A bit more about the powershell script : to be more flexibe, instead of having a configuration file, i'm using the variables of the releases so you can have multiple environments using the same file with different variables.

And instead of loading the SDK like in the original script, you have several choices :

  • Install the module in the GAC where the agent is running
  • Embed the assemblies in your code and directly load it from the artifact in the release step powershell script
  • Put it somewhere on the environment where the agent is running to load the module on the fly.
  • probably a lot of others possibilities !

Sample of powershell script successfull log :
Some files are ignored because they are matching the files from the CRM and the others are updated.

Quick recap :

In this article, i've went across a simple Continuous Integration of your webresources from the developer to the CRM without any manual actions.

So the developer does his commit for the new feature, bug fix or wathever and few seconds later the related webresources are updated in the CRM.

Hope this can help,
Happy CRM'ing,


Read more posts by this author.