web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

D365 FO Build Error on prepare for build Step

(0) ShareShare
ReportReport
Posted on by 5

Can anyone help me on how to solve this error. I had successfully built my first build but I had forgot to change the artifact for packages to be stored. So I changed that and queued another build and this is the error

  1. VERBOSE: 5:35:27 PM: - Metadata restored from backup with RoboCopy exit code:
    10.
    VERBOSE: 5:35:27 PM: - Exception thrown at
    C:\DynamicsSDK\PrepareForBuild.ps1:514: throw "Failed to restore metadata
    backup from: $BackupPath"
    System.Management.Automation.RuntimeException: Failed to restore metadata
    backup from: J:\DynamicsBackup\Packages
    Write-Message : 5:35:27 PM: Error preparing build environment: Failed to
    restore metadata backup from: J:\DynamicsBackup\Packages
    At C:\DynamicsSDK\PrepareForBuild.ps1:724 char:5
    + Write-Message "Error preparing build environment: $($_)" -Error
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
    tion
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
    n,Write-Message
    VERBOSE: Importing function 'Get-AX7SdkDeploymentBinariesPath'.
    VERBOSE: Importing function 'Get-AX7SdkTeamFoundationServerUrl'.
    VERBOSE: Importing function 'Write-Message'.
    6366.builderr.png
I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Moved to D365 Finance forum.

    What do you mean "change the artifact for packages to be stored"? Could you explain exactly what you changed?

    Anyway, if it feels like it would take more than 30 minutes of working time to investigate it, I recommend simply deploying a new system.

  • GNRS Profile Picture
    5 on at

    On the Agent Job; I have changed on "Publish Artifact: Packages"  - "Path to Publish" to my desired folder at DevOps.

    I'm assuming that this is the correct way to do it is to have the packages be at devops then upload the package to LCS.

    Anyhow, even if I reverted to old settings it still has the error above.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    As you noticed, this change has nothing to do with your error. Publishing the artifacts happens only after the build itself was succesful.

    So, my suggestion still stands: try to deploy a new system and see if that resolves your problem. It takes only some minutes of working time so most likely it's the cheapest next step in troubleshooting.

  • GNRS Profile Picture
    5 on at

    Hi,

    It seems the error is resolved by deleting the backup of the packages/clearing disk space. Then when the powershell "prepareforbuild" runs it should then retry.

  • Verified answer
    Joris dG Profile Picture
    17,775 on at

    If you deleted the backup manually, you need to ENSURE your packages local directory does NOT contain any custom code. Otherwise, when prepareforbuild runs it sees there is no backup and will take a new one - but now your custom code is PART of the backup. This will cause all sorts of problems.

  • Suggested answer
    GNRS Profile Picture
    5 on at

    Interesting. It is as you have explained. I am only testing the continuous delivery part of F&O and this is good to know.

    Anyhow I will be closing the thread

    Note:

    -Delete packages backup

    -no custom code should be in build machine(no devs allowed here)

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    One more thing: there can be custom code even if no devs worked in the system.

    Before the very first build, the system takes a backup of AOSService/PackagesLocalDirectory. At this point it doesn't contain any customizations.

    During the build, the system downloads your customizations from source control and compiles them. Now you have customizations in AOSService/PackagesLocalDirectory.

    On the next build, the system restores the backup that was taken before the first build (in order to start from clean slate before downloading latest code from source control). But if you deleted the backup, the system will now back up the current state of AOSService/PackagesLocalDirectory, which contains your customizations!

    So, the simples solution is to deploy a new build VM. Other option is to clean up your customizations from AOSService/PackagesLocalDirectory, and delete the backup of that folder one more time.

  • swetha desai Profile Picture
    152 on at

    removing customization from build server worked. thank you

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 677 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 421 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 317 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans