My team uses compiler directives to create different versions of our product for different stages (debug, test, release) but now we want to move a CI/CD strategy and we are discussing whether it is a good idea to use compiler directives at all since the artifact(s) produced for one configuration cannot be used for another, for example, our CI server runs the build process with the test configuration and all stages from the build process pass including UI automated tests, the artifacts created in this process cannot be deployed to production because for production the application needs to be compiled using the release configuration thus creating a new set of untested artifacts to deploy the production environment, which, in my opinion makes the work performed in the previous stage(s) obsolete because you probably want to run your tests against the newly created artifacts.
Has anyone had a similar similar situation and if so how did you address it with your team. Is it a good idea to use c# compiler directives when you want to move to a CI/CD strategy?