burnt1ce
burnt1ce

Reputation: 14897

MsBuild: Forcing a rebuild when changing build configuration

I have a #if in a project that depends on which build configuration is selected (eg: Debug, QA, and other test environments). When a user changes the build configuration in VS2015/Xamarin Studio, I need the IDE to force a rebuild on this project when the user builds the solution. How do I do this? At the moment, rebuilding the solution will reuse the compiled dll's.

In other words, how do I set a project dirty after a user changes the build configuration to force a rebuild.

Upvotes: 2

Views: 344

Answers (1)

jessehouwing
jessehouwing

Reputation: 114481

Make sure the Output path of the project is unique to the build configuration. Otherwise MsBuild will just compare the timestamp of the input files and the existing output files and will conclude that a rebuild is not required.

It is assumed that when two projects build a different configuration, that they also write to a different folder for this reason.

Normally the output location is set to .\bin\$(configuration) to ensure this is the default behavior.

Upvotes: 3

Related Questions