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
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.
The best solution I've found so far is to write a vs2008 add-in based on: http://msdn.microsoft.com/en-us/library/ms165638.aspx
public void OnPublishBegin(ref bool pubContinue)
{
if (pubContinue && _applicationObject.Solution.SolutionBuild.ActiveConfiguration.Name != "Release")
{
System.Windows.Forms.MessageBox.Show("You can only publish a Release build");
pubContinue = false;
}
}
Any other ideas are appreciated.
Sorry to tell you this, but there's no way to do this. And jomi is right, you get the dialog if you change the signing key, but not if you change the build configuration. You just have to pay close attention when deploying your product.
RobinDotNet
Visit my ClickOnce blog!
精彩评论