Skip to content

Instantly share code, notes, and snippets.

@tclancy
Last active May 28, 2021 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tclancy/ffbf3eadace913de9ce357566ae7506f to your computer and use it in GitHub Desktop.
Save tclancy/ffbf3eadace913de9ce357566ae7506f to your computer and use it in GitHub Desktop.
Microsoft Dynamics Power Apps Azure Build Pipeline
# Because there's nothing easily google-able for how to do this, here's
# a script to show the "basics" and create a permanent memorial to the
# week of my life it took to learn this
# 1. Install the Power Apps CLI via Powershell
# 2. Install node
# 3. Add node and install pcf-scripts (https://www.npmjs.com/package/pcf-scripts)
# 4. Run pcf scripts
# 5. Run msbuild on project file(s)
# 6. Run deployment Powershell script which looks like this:
# Install-Module Microsoft.Xrm.Data.PowerShell -Scope CurrentUser -Force
# Import-Module Microsoft.Xrm.Data.Powershell
# $conn = Connect-CrmOnline -ClientSecret $Env:CLIENT_SECRET -OAuthClientId $Env:CLIENT_ID `
# -ServerUrl "https://alliancefunding$Env:TARGET_ENVIRONMENT.crm.dynamics.com"
# Import-CrmSolution -conn $conn -SolutionFilePath "$ENV:BUILD_SOURCESDIRECTORY\MyComponentName\Solution\bin\Debug\Solution.zip" `
# -Verbose -OverwriteUnManagedCustomizations
trigger:
- master
pool:
vmImage: windows-latest
steps:
- task: PowerShell@2
displayName: 'Download and install Power Apps CLI'
inputs:
targetType: 'inline'
script: |
Invoke-WebRequest -Uri 'https://aka.ms/PowerAppsCLI' -MaximumRedirection 1 -OutFile 'installer.msi'
Start-Process 'installer.msi' -ArgumentList '/q' -Wait
- task: NodeTool@0
inputs:
versionSpec: '16.x'
- task: Npm@1
inputs:
command: 'install'
workingDir: '.'
- task: Npm@1
displayName: 'Run pcf scripts'
inputs:
command: 'custom'
customCommand: 'run build'
workingDir: '.'
- task: MSBuild@1
inputs:
solution: '**/*.cdsproj'
msbuildArguments: '/t:build /restore'
- task: PowerShell@2
displayName: 'Deploy components to $(TARGET_ENVIRONMENT) environment'
inputs:
targetType: 'filePath'
filePath: build.ps1
env:
CLIENT_ID: $(CLIENT_ID)
CLIENT_SECRET: $(CLIENT_SECRET)
TARGET_ENVIRONMENT: $(TARGET_ENVIRONMENT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment