From 6b15b9eafcfa32577f05b1d65496995fe92c2278 Mon Sep 17 00:00:00 2001 From: ikurtev Date: Wed, 18 Jan 2017 19:17:24 -0500 Subject: [PATCH 1/2] Added verbose switch to Get-CrmConnection based on recommendation from Microsoft. --- .../Xrm.Framework.CI.PowerShell.Scripts/DeployPackage.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/DeployPackage.ps1 b/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/DeployPackage.ps1 index 2843e487..cfd3eed5 100644 --- a/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/DeployPackage.ps1 +++ b/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/DeployPackage.ps1 @@ -47,8 +47,8 @@ $Cred = New-Object System.Management.Automation.PSCredential ($Username, $SecPas switch($DeploymentType) { - "Onpremises" { $CRMConn = Get-CrmConnection -ServerUrl $ServerUrl -OrganizationName $OrganizationName -Credential $Cred } - "Online" { $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion $DeploymentRegion –OnlineType $OnlineType –OrganizationName $OrganizationName } + "Onpremises" { $CRMConn = Get-CrmConnection -ServerUrl $ServerUrl -OrganizationName $OrganizationName -Credential $Cred -Verbose} + "Online" { $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion $DeploymentRegion –OnlineType $OnlineType –OrganizationName $OrganizationName -Verbose} } #Deploy Package From 2cd04d3d102ee8f9159e43bf1b76efc5146e67ef Mon Sep 17 00:00:00 2001 From: ikurtev Date: Fri, 10 Feb 2017 14:58:40 -0500 Subject: [PATCH 2/2] Removed check that verified that the Import Progress of the solution is 100% as solutions frequently import successfully with Import Progress less than 100%. Instead, added check that looks for any solution components in the Import Log file that have a result equal to "failure" which is a more reliable indicator if anything went wrong with the solution import. --- .../ImportSolution.ps1 | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/ImportSolution.ps1 b/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/ImportSolution.ps1 index edb8178a..b69ff129 100644 --- a/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/ImportSolution.ps1 +++ b/CRM365/Xrm.Framework.CI/Xrm.Framework.CI.PowerShell.Scripts/ImportSolution.ps1 @@ -91,16 +91,38 @@ if ($override -or ($solution -eq $null) -or ($solution.Version -ne $solutionInfo Write-Verbose "Import Error Text: $importErrorText" Write-Verbose $importJob.Data - if (($importResult -ne "success") -or ($importProgress -ne 100)) + if ($importResult -ne "success") { throw "Import Failed" } - $solution = Get-XrmSolution -ConnectionString $CrmConnectionString -UniqueSolutionName $solutionInfo.UniqueName + #parse the importexportxml and look for result notes with result="failure" + $importFailed = $false + $importjobXml = [xml]$importJob.Data + $failureNodes = $importjobXml.SelectNodes("//*[@result='failure']") - if ($solution.Version -ne $solutionInfo.Version) + foreach ($failureNode in $failureNodes){ + $componentName = $failureNode.ParentNode.Attributes['name'].Value + $errorText = $failureNode.Attributes['errortext'].Value + Write-Host "Component Import Failure: '$componentName' failed with error: '$errorText'" + $importFailed = $true + } + + if ($importFailed -eq $true) + { + throw "The Solution Import failed because one or more components with a result of 'failure' were found. For detals, check the Diagnostics for this build or the solution import log file in the logs subfolder of the Drop folder." + } + else + { + Write-Host "The import result of all components is 'success'." + } + #end parse the importexportxml and look for result notes with result="failure" + + $solution = Get-XrmSolution -ConnectionString $CrmConnectionString -UniqueSolutionName $solutionInfo.UniqueName + + if ($solution.Version -ne $solutionInfo.Version) { - throw "Import Failed" + throw "Import Failed. Check the solution import log file in the logs subfolder of the Drop folder." } else {