Visual Studio 后期生成事件可以与 ClickOnce 发布一起使用吗?

发布于 2024-09-26 10:43:07 字数 134 浏览 2 评论 0原文

在 Visual Studio 2008 中,构建后事件可以与 ClickOnce 发布一起使用吗?如果是这样,怎么办?

开箱即用,看起来我只能使用预构建事件,并且 ClickOnce 发布似乎在启动后构建事件之前将项目构建到不同的位置。

In Visual Studio 2008, can a post-build event be used with ClickOnce publishing? If so, how?

Out of the box, it looks like I can only use pre-build events and ClickOnce publishing seems to build the project to a different location, before the post build event is launched.

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

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

发布评论

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

评论(2

2024-10-03 10:43:07

查看 Visual Studio 使用的 MSBuild 文件,生成后事件由生成目标运行。如果您从命令行运行 msbuild 并直接调用 Publish 目标,它肯定会先调用 Build。如果右键单击 VS 中的项目并单击“发布”,则假设 VS 已完成构建,则会运行名为 PublishOnly 的精简目标。

当 Visual Studio 在发布之前自动生成项目时,应运行生成后事件。在项目属性的“构建事件”选项卡中,您是否将事件设置为“始终运行”?

如果您想更明确地了解发布之前发生的情况,则 Publish 始终会查找一个 BeforePublish 目标,无论它是由 MSBuild 还是 Visual Studio 运行。手动编辑项目文件,在底部您将看到几个注释掉的 Target 元素。添加您自己的任务之一,如下所示:

<Target Name="BeforePublish">
    <Exec Condition="'$(PostBuildEvent)' != ''" 
          WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>

这将运行您在项目中定义的相同的构建后事件,但您可以将任何 MSBuild 任务放入这些 Target 元素中。

Looking at the MSBuild files Visual Studio uses, the post build event is run by the Build target. If you run msbuild from the command-line and call the Publish target directly, it definitely calls Build first. If you right-click on the project in VS and click Publish, a trimmed-down target called PublishOnly gets run, on the assumption that VS has already done a build.

Your post build event should be run by Visual Studio when it automatically builds your project prior to publishing. In the Build Events tab of your project's properties, did you set the event to "run always"?

If you want to be more explicit about what happens prior to publishing, there's a BeforePublish target that Publish always looks for, whether it's run by MSBuild or Visual Studio. Edit your project file by hand, and at the bottom you'll see a couple of commented-out Target elements. Add one of your own like this:

<Target Name="BeforePublish">
    <Exec Condition="'$(PostBuildEvent)' != ''" 
          WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
</Target>

That will run the same post build event you defined in your project, but you could put any MSBuild tasks inside those Target elements.

听不够的曲调 2024-10-03 10:43:07

我想你会找到博客文章app.config 和 ClickOnce 部署的技巧很有用。它讨论了每种类型的部署都有不同的 app.config 文件。

I think you will find blog post Tricks with app.config and ClickOnce deployment useful. It talks about having different app.config files for each type of deployment.

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