-
Notifications
You must be signed in to change notification settings - Fork 70
EBG ‐ Integrating The Early Bound Generator Into Your Build Pipeline
- Copy the contents of the DLaB.EarlyBoundGeneratorV2 in the XrmToolBox Plugins directory (Default: C:\Users{UserName}\AppData\Roaming\MscrmTools\XrmToolBox\Plugins\DLaB.EarlyBoundGeneratorV2)
- Paste the entire directory into the latest version of PAC Tools directory (C:\Users{UserName}\AppData\Local\Microsoft\PowerAppsCli\Microsoft.PowerApps.CLI.X.X.X\tools). This will end up with a \tools\DLaB.EarlyBoundGeneratorV2 directory in the PAC directory.
- Move the DLaB.ModelBuilderExtensions.dll up a directory from the \tools\DLaB.EarlyBoundGeneratorV2 directory to the tools directory
- Create an AUTH in the PAC if it doesn't already exist (Example using App/Secret: PAC auth create --name {NAME} --tenant {TENENT_ID} --applicationId {APP_ID} --clientSecret {APP_SECRET} --url https://{ORG_URL_NAME}.crm.dynamics.com/)
- Run the command line of the tool the Early Bound Generator spits out (PAC modelbuilder build --outdirectory {OUTPUT_DIRECTORY} --settingsTemplateFile {PATH_TO_builderSettings.json})
Please note Everything below this line was written for the CrmSvcUtil version of the Early Bound Generator (EBG V1) This may not apply to the PAC Modelbuilder version
- GUI DLaB.EarlyBoundGenerator.Settings.xml file - This is the file defined in the Settings path of the GUI. It stores the serialized settings that the Early Bound Generator uses to populate the UI and to generate the item, the CrmSvcUtil.exe.config. The path of which is also used to resolve relative paths for generation of the output files. This can be renamed if desired.
- CrmSvcUtil Folder - By default this comes nested in the Plugins folder of the XrmToolBox. The path is configurable so it can be placed wherever you'd like as long as it includes the required files.
- CrmSvcUtil.exe.config - This is recreated each time a request is made in the EBG UI to regenerate classes.
- Command Line - The command line is spit out (minus the password) in the Text Box in the UI when regenerating classes, as well as in the main class file for each type (Actions.cs, Entities.cs/CrmContext.cs, OptionSets.cs)
- Define your Settings.xml file.
- First copy the default DLaB.EarlyBoundGenerator.Settings.xml to a folder within your source control map on your machine. It is recommended that this folder is below the VS solution file that uses early bound entities so if someone gets latest on the solution folder, they'll get the latest generator settings.
- Run the Early Bound Generator in the XrmToolBox, connecting to the dev org and selecting the settings file from the source control folder from 1.i. The Early Bound Generator will tie the generator setting to each org, so if you have multiple clients, each client can have different settings.
- Configuring the settings however you'd like until you're satisfied. Be sure to have the output paths be relative paths, relative to the location of the settings.xml file. from 1.i.
- Generate all entities/actions/option sets. Verify the output is correct and that the entities/project files in your VS solution have been correctly updated.
- Important Close the Early Bound Generator in XrmToolbox to save the settings to your .xml file.
- Communicate to the Team these steps for how to generate the files.
- Always get the latest version of the settings.xml from 1.i before opening the Early Bound Generator.
- Connect to the dev org from which entities should be generated from. Double check that the settings file is the correct file from source control.
- Tweak any settings as needed (add a new entity/action to the white list, etc).
- Generate all.
- Close the Early Bound Generator and check in the changes.
- Enjoy an early bound world!
Follow the steps from the Recommendation for Manual Generation in a "Team Safe" way section above, except that the location of the CrmSvcUtil folder should be moved to a folder in source control (Or you can use the EBG.API Nuget file if you can't bring yourself to check in dlls and an exe into source control. You'll need to copy over the CrmSvcUtil.exe.config file if you do this though as a part of your build process, once the nuget file is downloaded, but before the files are generated). Then your build process will need to run the command lines that are normally ran by the GUI, or you can use the powershell method below.
Any future configurations can be made directly to the CrmSvcUtil.exe.config, or via the GUI by running the tool once after making the desired updates.
If you need to run this as a part of your build, use this PowerShell script:
param(
[string]$crmServerUrl,
[string]$targetDir,
[string]$toolsDir
)
$arguments=@("/url:`"$crmServerUrl`"",
"/namespace:`"Scam.Xrm.EntityWrappers`"",
"/out:`"$targetDir\CrmServiceContext.cs`"",
"/servicecontextname:`"CrmServiceContext`"",
"/codecustomization:`"DLaB.CrmSvcUtilExtensions.Entity.CustomizeCodeDomService,DLaB.CrmSvcUtilExtensions`"",
"/codegenerationservice:`"DLaB.CrmSvcUtilExtensions.Entity.CustomCodeGenerationService,DLaB.CrmSvcUtilExtensions`"",
"/codewriterfilter:`"DLaB.CrmSvcUtilExtensions.Entity.CodeWriterFilterService,DLaB.CrmSvcUtilExtensions`"",
"/namingservice:`"DLaB.CrmSvcUtilExtensions.NamingService,DLaB.CrmSvcUtilExtensions`"",
"/metadataproviderservice:`"DLaB.CrmSvcUtilExtensions.Entity.MetadataProviderService,DLaB.CrmSvcUtilExtensions`""
)
Start-Process -FilePath "crmsvcutil.exe" -WorkingDirectory "$toolsDir" -ArgumentList $arguments -Wait
- Install the EBG DevOps Tools from the Visual Studio marketplace to your Azure DevOps organization.
- Add the EBG DevOps Tools tasks to your pipeline.
- Add the EBG DevOps Tool Installer task to your pipeline first.
- This task is a pre-requisite to the Early Bound Generator task as it sets the required versions of the dependencies.
- Optionally override the version of DLaB.Xrm.EarlyBoundGenerator.Api (1.2021.12.12) to match the Early Bound Generator Version from your DLaB.EarlyBoundGenerator.Settings.xml file. Alternatively, you may specify latest to use the latest version.
- Add the Early Bound Generator task to your pipeline.
- This task performs the generation of the Early Bound XRM Classes (Actions, Entities and Option Sets) by invoking CrmSvcUtil.exe via DLaB.Xrm.EarlyBoundGenerator.Api.
- The Connection String must follow the conventions outlined in the Microsoft Dataverse documentation.
- The Settings Path should point to the DLaB.EarlyBoundGenerator.Settings.xml.
- The Creation Type allows you to specify which type of Early Bound XRM Classes to generate (Actions, Entities, Option Sets or All).
- Add the EBG DevOps Tool Installer task to your pipeline first.