I am using visual studio 2019 for a c++ project. In this project, I generate a cpp file on build (pre-build event) and, if needed, modify the .vcxproj in order to add the file to the project. When the file is already present and thus only overwritten, it works perfectly.
However, if I want to generate the file and add it at the start of compilation, it won't detect the file and I will need to hit compile again in order for it to work (as it has been generated and added on the first compile, even though it failed). There is also a pop-up window at the end of the first compile telling me some files were changed and asking me what to do (reload/reload all/ignore/ignore all).
Is there a way to make it work on first try ? Maybe with a custom build event set before anything else ? Or is there a way to modify the execution order of build events ? (to set pre-build events before anything else)