Closed mschoneman closed 2 years ago
Thanks for reaching out, sorry you're having some trouble with this, I setup a test just to make sure it was working for me and so far it's working well. Can you share how you've configured your build pipeline? I also tried windows-2019.
It's a YAML pipeline:
trigger:
- main
stages:
- stage: TestCRM
displayName: TestCRM
jobs:
- job: TestPowerShell
pool:
vmImage: windows-latest
steps:
- task: AzurePowerShell@5
displayName: 'Test Dynamics 365 Connection'
inputs:
azureSubscription: 'DevTest'
ScriptPath: 'TestDynamicsConnection.ps1'
azurePowerShellVersion: LatestVersion
pwsh: false
Here's the script:
Install-Module Microsoft.Xrm.Data.PowerShell -Scope CurrentUser -AllowClobber -Force -Verbose -SkipPublisherCheck -AcceptLicense
Import-Module Microsoft.Xrm.Data.Powershell -verbose
$connection = Connect-CrmOnline -ServerUrl https://xxx.crm.dynamics.com -ClientSecret <hardcoded for test> -OAuthClientId <hardcoded for test>
$connection
if ($connection.IsReady)
{
Write-Host("Connected")
} else {
throw "Not connected"
}
Are you using powershell core? If so, it isn't compatible with .NET framework modules and that very well could be the problem. I believe non-core powershell scripts are PowerShell@2
Shouldn't be. The pwsh: false
should according to the docs use regular powershell instead of ps core
Script works fine on my local box (still) and had been running without issue in Azure DevOps until Oct 21. After that started failing in Azure DevOps.
Based on your comment I switch from the AzurePowerShell@5
task to the PowerShell@2 task
and things seem to be working. Not sure what changed in the DevOps environment, but I'll just be happy that it is working. Thanks for the help, I appreciate your time and the library you've provided.
We've been using this library for a while, but just started getting the following error yesterday:
Unable to connect to CRM: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.Unable to Login to Dynamics CRM Unable to Login to Dynamics CRMOrganizationWebProxyClient is null OrganizationWebProxyClient is null
Any thoughts?