Search code examples
c#azure-devopsdynamics-crmdevops

Azure DevOps - PowerApps package Deployer - You cannot call a method on a null-valued expression


I am trying to run packagedeployer using PowerApps Deploy Package and getting an error "You cannot call a method on a null-valued expression". This is a CRM Package solution that is created using Dynamics 365 SDK templates. Please find below the link with details

https://learn.microsoft.com/en-us/powerapps/developer/common-data-service/package-deployer/create-packages-package-deployer#create-a-package

Azure DevOps Error Screenshot


Solution

  • "You cannot call a method on a null-valued expression"

    The information is not enough to solve the problem, but i can suggest a way you can troubleshoot.

    First, set the system.debug value to "true" in your pipeline Variables,

    enter image description here

    and then run the build again and you shall see the detailed exception message in the debug information(with ##[debug] before them) in the log information.

    Most likely you will see it's a ps1 file that raised the error since the error message you cannot call a method on a null-valued expression usually occurs in ps script and it should points out in which line which char you got the error.

    Then, add a PowerShell Script task down below your PowerApps Deploy Package task, add an Inline script using the Get-Content method:

    Get-Content -Path {path you find in above task log information}
    

    Now you are able to see which line in the script caused the problem and find a way to solve it, or update what you find in your question post and we will keep on.

    Below are some reference links you can check:

    Troubleshoot the InvokeMethodOnNull Error with PowerShell

    You cannot call a method on a null-valued expression