Disallow publishing of debug builds for ClickOnce deployment

clickonce

Is there a way to disallow publishing of debug builds with ClickOnce?

I only want to allow release builds through, but right now human error causes a debug build to slip through once in a while.

We're publishing the build from within Visual Studio.

Best Answer

One thing you can do is add a condition to the .csproj or .vbproj file that MSBuild will check when doing a build.

The condition would check if a publish is occurring and check if the build is a debug build, then do something like run an external tool or otherwise interrupt the build process or cause it to fail.

An example might be something like this:

<Choose>
    <When Condition=" '$(Configuration)'=='Debug' ">
        <Exec Command="C:\foo.bat" ContinueOnError="false" />
    </When>
 </Choose>

Where foo.bat is a batch file that return non-zero, thus stopping the publish from occurring.

Related Topic