在 Visual Studio 2008 中向网站添加构建后事件

发布于 2024-07-16 08:53:16 字数 88 浏览 6 评论 0原文

我正在使用 Visual Studio 2008 中的“网站”,并且我想添加一个构建后事件,该事件会将构建时间附加到 web.config 文件中。 是否可以?

I am using a "web site" in visual studio 2008, and i would like to add a post-build event which would append the build time to the web.config file. Is it possible?

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

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

发布评论

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

评论(6

慈悲佛祖 2024-07-23 08:53:16

恐怕网站不支持此功能,您需要使用网络应用程序项目。

I'm afraid this isn't supported for web sites, you'll need to use a web application project.

时光与爱终年不遇 2024-07-23 08:53:16

采用 WAP(Web 应用程序项目)而不是 WSP(网站项目)的主要好处之一是您能够进行构建后事件。

因此,无论如何也不可能开箱即用。 详细信息

One of the major benefits of going the WAP (Web Application Projects) route rather than WSP (Website Projects) is that you get the ability to have Post Build events.

Therefore, it is not possible out of the box anyway. Here is the detail.

茶色山野 2024-07-23 08:53:16
  1. 添加一个单独的(空)项目(“.buildstep”),您可以在其中添加自定义构建步骤 - 您必须为主 Web 项目指定目标文件夹,但要使用预定义的环境变量(例如 $solutiondir、 $平台、$模式等)。
  2. 从主 Web 项目添加对此新项目的依赖项(项目 | 项目依赖项)。
  3. 重建+验证构建步骤已执行。 你完成了。
  4. ;o)
  1. Add a separate (empty) project (".buildstep"), to which you add your custom build step - you'll have to specify target folders to the main web project, but make use of the predefined environment variables (like $solutiondir, $platform, $mode etc).
  2. Add a dependency to this new project from the main web project (Project | Project Dependencies).
  3. Rebuild + verify build step has been carried out. You're done.
  4. ;o)
雪化雨蝶 2024-07-23 08:53:16

也许它不相关,但您可以自定义启动选项(使其运行脚本/命令),尽管只有当您启动项目(Dubug -> Start)时才会触发它。

Maybe it is no relevant, but you can customize start options (make it run script/command) though it will be triggered only when you Launch project (Dubug -> Start).

吻安 2024-07-23 08:53:16

一种可能的解决方案是创建一个没有任何文件的空虚拟 C#/VB 项目,并在其中添加必要的批处理脚本作为构建后事件。 然后,您可以在发布网站后立即构建该“项目” - 额外单击鼠标,但仍然比手动运行更好。 我采用了这条路线来进行部署打包,效果非常好。

One possible solution is creating an empty dummy C#/VB project without any files, and adding the necessary batch script as post build event there. Then, you can build that "project" right after you publish the web site - an extra mouse click but still better than running things manually. I went this route for our deployment packaging and it works great.

蝶舞 2024-07-23 08:53:16

您可以为网站类型应用程序创建发布配置文件。
应创建 *.publishproj
然后您可以将 postpre 构建命令添加为目标

<Target Name="BeforeBuildTarget" AfterTargets="BeforeBuild">
    <Exec Command="cmd.exe"></Exec>
</Target>
<Target Name="AfterBuildTarget" AfterTargets="AfterBuild">
    <Exec Command="cmd.exe"></Exec>
</Target>

You can create publish profile for Web Site type applications.
*.publishproj should be created.
Then you can add there post and pre build commands as Targets.

<Target Name="BeforeBuildTarget" AfterTargets="BeforeBuild">
    <Exec Command="cmd.exe"></Exec>
</Target>
<Target Name="AfterBuildTarget" AfterTargets="AfterBuild">
    <Exec Command="cmd.exe"></Exec>
</Target>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文