Using MSBuild with XrmToolkit.

XrmToolkit provides several MSBUILD targets that can be used to execute custom actions before or after certain actions have been performed by XrmToolkit during the build and publish of plugin assemblies.

  • XRMTK_BeforeBuild - Called before using the built in build process of Visual Studio
  • XRMTK_AfterBuild - Called after the build process of Visual Studio
  • XRMTK_BeforeILMerge - Called before merging the assemblies using ILMerge
  • XRMTK_AfterILMerge - Called after merging the assemblies with ILMerge
  • XRMTK_BeforePublishAssembly - Called before publishing the assembly to CRM
  • XRMTK_AfterPublishAssembly - Called after publishing the assembly to CRM
Deprecated:

The following are still available for backwards compatibility:

  • CRMSM_BeforeBuild - Called before using the built in build process of Visual Studio
  • CRMSM_AfterBuild - Called after the build process of Visual Studio
  • CRMSM_BeforeILMerge - Called before merging the assemblies using ILMerge
  • CRMSM_AfterILMerge - Called after merging the assemblies with ILMerge
  • CRMSM_BeforePublishAssembly - Called before publishing the assembly to CRM
  • CRMSM_AfterPublishAssembly - Called after publishing the assembly to CRM

To call the MSBUILD target you can add the following to your project file:

<Target Name="XRMTK_BeforeBuild">
    <Message Text="CRM Organization - $(CrmOrganization)" />
    <Message Text="CRM Organization URL - $(CrmOrganizationURL)" />
</Target>

The following parameters are passed to the custom targets:

  • CrmOrganization - Organization Name
  • CrmOrganizationFriendlyName - Organization Friendly Name
  • CrmOrganizationURL - Organization URL
  • CrmDiscoveryURL - Discovery URL
  • CrmSolution - Currently selected solution name
  • CrmSolutionId - Currently selected solution GUID
  • CrmUserName - Currently logged in user