防止使用 ClickOnce 部署调试版本

发布于 2024-08-28 13:53:02 字数 290 浏览 5 评论 0原文

我正在使用 VS2008 发布 ClickOnce 应用程序,但在每次发布之前我都必须手动切换到发布配置。只要我不忘记切换就可以了。有没有办法阻止部署调试版本?是否有一些编译器指令,例如:

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

或者有没有一种方法(无需构建脚本)在发布之前自动切换到发布配置?

(我发现了一些类似的问题,但不喜欢它们的答案)

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花辞树 2024-09-04 13:53:02

不确定这是否令人皱眉,但请在相关线程中查看我的答案:

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

简而言之,您可以修改项目文件以在发布之前检查调试符号,如果找到则抛出错误条件。这可以防止在不需要任何 .bat 文件或外部处理的情况下进行部署。

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.

失而复得 2024-09-04 13:53:02

到目前为止我发现的最好的解决方案是编写一个基于以下内容的 vs2008 加载项: 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;
        }
    }

任何其他想法表示赞赏。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文