A GitHub Action that installs Microsoft.CrmSdk.CoreTools and sets the CRM_SDK_PATH environment variable for use in CI/CD workflows.
- Installs Microsoft.CrmSdk.CoreTools package (latest or specific version)
- Supports version pinning for reproducible builds
- Sets
CRM_SDK_PATHenvironment variable for subsequent workflow steps - Skips installation if SDK is already installed
- Automatic cleanup of temporary files
- name: Setup CRM SDK
uses: marcus-hooper/setup-crmsdk@v1| Input | Required | Default | Description |
|---|---|---|---|
version |
No | (latest) | Specific version of Microsoft.CrmSdk.CoreTools to install (e.g., 9.1.0.184) |
- name: Setup CRM SDK
id: crmsdk
uses: marcus-hooper/setup-crmsdk@v1
- name: Run SolutionPackager
run: |
$solutionPackager = Join-Path $env:CRM_SDK_PATH "coretools\SolutionPackager.exe"
& $solutionPackager /action:Extract /zipfile:solution.zip /folder:solution
shell: powershell- name: Setup CRM SDK
id: crmsdk
uses: marcus-hooper/setup-crmsdk@v1
- name: Display SDK path
run: echo "SDK installed at ${{ steps.crmsdk.outputs.sdk-path }}"- name: Setup CRM SDK
uses: marcus-hooper/setup-crmsdk@v1
with:
version: '9.1.0.184'Here's a complete workflow that extracts a Dynamics 365 solution:
name: Extract Solution
on:
push:
branches: [main]
jobs:
extract:
name: Extract Solution
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
- name: Setup CRM SDK
id: crmsdk
uses: marcus-hooper/setup-crmsdk@v1
- name: Extract solution
run: |
$solutionPackager = Join-Path $env:CRM_SDK_PATH "coretools\SolutionPackager.exe"
& $solutionPackager /action:Extract /zipfile:MySolution.zip /folder:./solution /packagetype:Both
shell: powershell
- name: Upload extracted solution
uses: actions/upload-artifact@v6
with:
name: solution
path: ./solution| Output | Description |
|---|---|
sdk-path |
Path to the installed CRM SDK directory |
This action sets the following environment variable:
| Variable | Description |
|---|---|
CRM_SDK_PATH |
Path to the installed CRM SDK tools directory |
The action installs the Microsoft.CrmSdk.CoreTools NuGet package. The tools are located in the coretools subdirectory under CRM_SDK_PATH:
- SolutionPackager.exe - Pack and unpack Dynamics 365 solution files
- PackageDeployer.exe - Deploy packages to Dynamics 365
- CrmSvcUtil.exe - Generate early-bound entity classes
- PluginRegistration.exe - Register plugins and custom workflow activities
Access tools using: Join-Path $env:CRM_SDK_PATH "coretools\ToolName.exe"
- Windows runner (
runs-on: windows-latest) - Internet access to download NuGet packages
- Windows only - Requires Windows runner; not compatible with Linux or macOS
- Network required - Downloads NuGet CLI and packages at runtime
- Fixed install path - Always installs to
$env:LOCALAPPDATA\Programs\
- Checks if
CRM_SDK_PATHis already set (skips installation if exists) - Creates installation directory at
$env:LOCALAPPDATA\Programs\ - Downloads NuGet CLI from
dist.nuget.org - Installs
Microsoft.CrmSdk.CoreToolspackage via NuGet (specific version if provided, otherwise latest) - Locates
SolutionPackager.exeand setsCRM_SDK_PATHto its directory - Exports the path to
GITHUB_ENVfor subsequent workflow steps - Cleans up the NuGet CLI
When the action runs successfully, you'll see output similar to:
[INFO] Checking for existing CRM SDK installation...
[INFO] Downloading NuGet CLI...
[INFO] Installing Microsoft.CrmSdk.CoreTools...
[INFO] Package installed successfully
[INFO] Setting CRM_SDK_PATH to C:\Users\runneradmin\AppData\Local\Programs\Microsoft.CrmSdk.CoreTools.9.1.x\content\bin\coretools
[INFO] SDK installation complete
When the SDK is already installed:
[INFO] Checking for existing CRM SDK installation...
[INFO] CRM SDK is already installed at C:\Users\runneradmin\AppData\Local\Programs\Microsoft.CrmSdk.CoreTools.9.1.x\content\bin\coretools
[INFO] Skipping installation
| Issue | Cause | Solution |
|---|---|---|
Unable to download NuGet |
Firewall or network restrictions | Ensure runner has access to dist.nuget.org |
Package not found |
NuGet.org unreachable | Check network connectivity and retry |
SolutionPackager.exe not found |
Package structure changed | Open an issue with the error details |
| Action completes but tools not available | CRM_SDK_PATH not in path |
Use $env:CRM_SDK_PATH or the sdk-path output |
| Action skipped installation | SDK already installed | This is expected behavior; the action reuses existing installations |
- Check workflow logs - Expand the "Setup CRM SDK" step for detailed output
- Verify environment variable - Add a step to echo
$env:CRM_SDK_PATH - Check runner type - This action only works on Windows runners
- Self-hosted runners - Ensure write access to
$env:LOCALAPPDATA\Programs\
- PowerShell 5.1+ (Windows)
- PSScriptAnalyzer (for linting)
# Run the script directly
.\scripts\Install-CrmSdk.ps1
# Check if environment variable was set
$env:CRM_SDK_PATH
# Verify SolutionPackager exists
Test-Path (Join-Path $env:CRM_SDK_PATH "coretools\SolutionPackager.exe")# Install PSScriptAnalyzer if needed
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
# Run linter
Invoke-ScriptAnalyzer -Path ./scripts -Recurse -Settings PSGallery# Check formatting (CI runs this automatically)
Get-ChildItem -Path ./scripts -Include *.ps1,*.psm1 -Recurse | ForEach-Object {
$original = Get-Content -Path $_.FullName -Raw
$formatted = Invoke-Formatter -ScriptDefinition $original
if ($original -ne $formatted) {
Write-Host "Needs formatting: $($_.Name)"
}
}
# Auto-format a file
$content = Get-Content -Path ./scripts/Install-CrmSdk.ps1 -Raw
Invoke-Formatter -ScriptDefinition $content | Set-Content -Path ./scripts/Install-CrmSdk.ps1# Run Pester tests
Invoke-Pester -Path ./tests -Output Detailedsetup-crmsdk/
├── action.yml # GitHub Action definition (composite action)
├── scripts/
│ ├── Install-CrmSdk.ps1 # Entry point script
│ └── Install-CrmSdk.psm1 # PowerShell module with testable functions
├── tests/ # Pester unit tests
├── .github/
│ ├── ISSUE_TEMPLATE/ # Bug report and feature request forms
│ └── workflows/ # CI, CodeQL, security, release workflows
├── CHANGELOG.md # Version history
├── CONTRIBUTING.md # Contribution guidelines
└── SECURITY.md # Security policy
Contributions are welcome! Please see CONTRIBUTING.md for detailed guidelines.
Quick start:
- Check existing issues or open a new one
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes and add tests if applicable
- Ensure CI passes (lint, format, and test)
- Submit a pull request
See the issue templates for bug reports and feature requests.
- Microsoft.CrmSdk.CoreTools - The NuGet package this action installs
- Microsoft Power Platform CLI - Modern CLI alternative (pac CLI)
- Power Platform Actions - Official Microsoft GitHub Actions for Power Platform
See SECURITY.md for security policy and reporting vulnerabilities.
MIT License - see LICENSE for details.