D365FO Azure Build restores deleted objects

We are using VSTS with D365FO. When we delete any objects, check-in & then perform build from VSTS, it throws error related to the missing objects. And the deleted files are created again in the folder and objects are visible in AOT after the build. Why does such an issue occur & how to resolve it?

I don’t see such behavior.

Can you confirm that the object doesn’t exist in Azure DevOps repository anymore (using Source Control Explorer or Azure DevOps portal)?

What exactly does the error say?

Yes. We checked Azure DevOps Repository & the objects are not present there. Checked via both Source Control Explorer & Azure DevOps Portal. But as soon as we perform Azure build, the file reappears.

There are no errors in build except lets say an object which is deleted is referencing another object which is deleted, it will throw error that it cannot find the referenced object. If we check-in the same object with no code, for e.g., delete all code from class methods but keep the methods as they are referenced somewhere, then it works perfectly without any error. Even after this build, and the fact that we can see the file in file explorer, it is still not present in Azure DevOps Repository.

It sounds like that your Build box hasn’t been set up correctly. Your old code somehow got into the backup that is restored at the beginning of each build and therefore you don’t get a clean environment (which is the goal of this restore).

You can either clean up your current Build box or simply drop it and deploy a new one.