views:

148

answers:

2

Hi,

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

+1  A: 

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!

RobinDotNet
+1 cause the blog is awesome. You now have a new reader.
SnOrfus
Thanks! I have some upcoming entries on .NET 4.0 and ClickOnce. Hope they are helpful!
RobinDotNet
A: 

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.

jomi