The case of the missing xml file

Our automated deployment of a CRM Solution file started failing recently and it was quite a journey to find out what was causing the error.

We automate the deployment of our CRM solutions using the Build/Release processes in Visual Studio Team Services (VSTS). In short the process looks like this:

  1. Using the Dynamics 365 Developer Toolkit, we extract and unpack a solution into a customisations project in Visual Studio.
  2. We check these customisations into VSTS.
  3. This triggers a build of the solution, and we use Wael Hamze’s VSTS Extensions to pack the solution back into a deployable zip file
  4. The successful build process triggers a release to CRM, using the powershell utilities from the ALM toolkit from ADXStudio. (We can’t use Wael’s solution for this because it doesn’t work with our version of CRM 2015).

The first thing we knew was that our automated release started failing in VSTS with the error:

“importjob With Id = feb7b87f-1ff9-4914-ba14-0116ca959584 Does Not Exist”

As you can see from the logs, the import gets kicked off and then fails within a couple of minutes with the ‘import job does not exist’ error.

A few searches around the topic seemed to suggest that the issue could be caused by timeouts when uploading large solution files, but this did not seem to be the case for us as we would not expect the timeouts to suddenly start occurring persistently after one fairly minor check-in. Also the deployments of this large solution normally take 5-10 minutes, whereas the error was occurring in less than 2 minutes.

The first thing we tried was to see if we could import the solution file as exported directly from the CRM front-end, using the front-end solution import process.

This worked OK, so we then tried importing the solution file that is created as part of the automated build in step 3 above.

So we copied the solution file from the server where the VSTS agent runs and tried to import this through the CRM front-end. This failed almost immediately with the following error:

So, now, we’ve got something to work with – there’s something wrong with the file that the solution packager is creating.

Switching verbose tracing on on the server to which we are deploying enabled us to find a more helpful error message in the w3wp-CRMWeb trace file:

Crm Exception: Message: The import file is invalid. XSD validation failed with the following error: ‘The element ‘EntityRelationship’ has incomplete content. List of possible elements expected: ‘EntityRelationshipType’.’. The validation failed at:…

Googling the error message took us to this very useful article which suggested that the issue might be that a relationship mentioned in the Relationships.xml file in the ‘Other’ folder in the unpacked solution, might not have a corresponding file in the Relationships folder. Sure enough, the relationships.xml file contained a reference to a newly created relationship, and the Visual Studio project contained a reference to the definition file for this relationship which had not been checked into source control:

Checking that missing file into source control fixed the problem.

Lessons learned:

1.) Those error messages are not always what they seem – sometimes the only place you’ll get really useful information is the CRM trace logs.

2.) Make sure you add any new files which are part of your customisation project into source control.

 

Posted in CI, Dynamics CRM, Uncategorized | Tagged | Leave a comment

Leave a Reply