This project is read-only.

In this post I will show you how to create a Build Definition to Pack your CRM Solution. Before you proceed ensure you were able to successfully create and run the “SampleBase” Build Definition I covered in the previous post.

During the solution pack, the process template will go through several optional stages in the order below. These are in addition to the steps covered in the “SampleBase” build definition.

  1. Update CRM Solution Version to Build Number
  2. Pack CRM Solution

Before you can create your build definition, you will need to have all your solution files extracted and stored in source control along with your mapping file and solutionpackager.exe.

To learn more about development using the Solution Packager and how to automate the extraction of your CRM Solution from your Development CRM Orgnization to source control, you can refer this post on my blog.

Below is a screen shot of all the solution files in source control that I will need for the build.

image

image

image

The mapping file that you will use for a TFS Build needs to take into consideration where TFS places the output files.

If you build something in visual studio. Your output files will be placed something like the below. So the source and outputs are mixed together.

[Solution/Folder][ProjectName]\[bin]\[Configuration] – e.g. Sample\Plugins\bin\Debug\Sample.Plugins.dll

Code Snippet
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Mapping>
  3.  
  4.   <FileToFile map="SamplePlugins.dll" to="..\Sample\CrmPackage\bin\Release\Sample.Plugins.dll" />
  5.   <FileToFile map="SampleWorkflow.dll" to="..\Sample\CrmPackage\bin\Release\Sample.Workflow.dll" />
  6.  
  7.   <FileToPath map="WebResources\*.*" to="..\Sample\CrmPackage\WebResources\**" />
  8.  
  9. </Mapping>

 

When TFS builds source code on the Build Server, My default it will push all the outputs to the same folder excluding the project names. Source files are stored in a different folder too. Take a look at the structure below as an example.

[BuildWorkingFolder]\src\[SourceFiles]
[BuildWorkingFolder]\bin\[OutputFiles]

So your mapping file needs to look like something like the below.

Code Snippet
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Mapping>
  3.  
  4.   <FileToFile map="SamplePlugins.dll" to="..\..\Bin\Sample.Plugins.dll" />
  5.   <FileToFile map="SampleWorkflow.dll" to="..\..\Bin\Sample.Workflow.dll" />
  6.  
  7.   <FileToPath map="WebResources\*.*" to="..\Sample\CrmPackage\WebResources\**" />
  8.  
  9. </Mapping>

 

Once you have all the required components in source control. Follow the below steps to create your build definition.

You can either enhance your “SampleBase” build definition and clone the “SampleBase” build definition following the steps in the previous post.

Steps…

  1. Enter name for your Build Definition
    image
  2. Ensure all the required files are added to the workspace. These will be downloaded to the [BuildWorkingDirectory]\src during the build.
    image
  3. Most of the configuration was already provided in the “SampleBase” build definition so we just need to fill the below.
    image
  4. Set the below to True to allow the build definition to update/check-in the new solution version in source control.
    image

    image
  5. Set the below to True to enable the solution pack otherwise this whole section will be skipped.
    image
  6. Set this to include the solution version as part of the generated zip file.
    image
  7. Select if you want to generate the Managed, Unmanaged Solutions zip or Both.
    image
  8. Set the below to True to set the solution version to the build number (part after ‘_’). Note this only update the file locally and will not be inline with your development environment at that point.
    image
  9. Select the folder containing your extracted solution files in source control.
    image
    image
    ne
  10. Set this to a relative folder path if you want your generated solution to be placed in a specific folder in the build output folder.
    image
  11. Set the path to the solution packager in source control.
    image
  12. Finally set the mapping file if you are using one.
    image
  13. Go ahead save this build definition and queue a new Build.
    image
  14. If the Build fails it will show as partially succeeded.
    image
  15. You should be able to see the CRM solution files generated. Note we did not need to supply a connection string to CRM as the Solution were generated from source control. Similar to the Export you will also see a manifest.xml file containing the solution details.
    image
  16. If you take a look at the diagnostics logs you should able to see the build log including the solution packager output.
    image

    image
  17. Now you should have a build definition that you can trigger manually or schedule to build your CRM Solution completely from source control. If you have more than one CRM solution you can create a build definition for each as most likely you will need to release these separately. If your requirement is more complex you can extend the template and/or PowerShell scripts to make it suite your needs.

Last edited Aug 5, 2014 at 8:33 PM by waelhamze, version 4