Search code examples
c#deploymentclickoncevisual-studio-debugging

Prevent deploying debug build with ClickOnce


I'm publishing a ClickOnce application with VS2008, but before every publish I have to switch to Release config manually. This is fine as far as I don't forget to switch. Is there a way to prevent deploying debug builds ? Is there some compiler directive like:

#if DEBUG
#if ClickOnce
#error You cannot publish a debug build
#endif
#endif

Or is there a way (without build scripts) to automatically switch to Release config before publishing ?

(I've found some similar questions but didn't like the anwsers on them)

Thanks


Solution

  • Not sure if this is frowned upon, but please see my answer in the related thread:

    https://stackoverflow.com/a/15080048/571237

    In short you can modify the project files to check for debug symbols before publishing, and throw an error condition if they're found. This prevents the deploy from happening without needing any .bat files or external processing.