批处理文件在发布后运行

时间:2021-09-13 02:17:11

Is there a way to execute a batch file after publishing a web application i.e. after using the 'Publish' option.

有没有办法在发布Web应用程序后执行批处理文件,即使用“发布”选项后。

I have read a few other questions on here which suggest the following:

我在这里已经阅读了一些其他问题,其中提出了以下建议:

1) Add AfterPublish attribute to the Project file:

1)将AfterPublish属性添加到Project文件:

<Target Name="CustomPostPublishActions" AfterTargets="MSDeployPublish" >
    <Exec Command="echo Post-PUBLISH event: Active configuration is: $(ConfigurationName)" />
</Target>

This does not seem to work. Is this only relevant to Visual Studio 2010?

这似乎不起作用。这仅与Visual Studio 2010有关吗?

2) Add the batch file location to the AfterBuild Text box as shown in the screenshot below:

2)将批处理文件位置添加到AfterBuild文本框,如下面的屏幕截图所示:

批处理文件在发布后运行

After Build runs before the publish so this will not work. How can I do this in Visual Studio 2008?

Build之后在发布之前运行,因此这将不起作用。如何在Visual Studio 2008中执行此操作?

1 个解决方案

#1


1  

As this post states:

正如这篇文章所述:

The following command duplicates the Publish Web Site dialog with default settings.

以下命令使用默认设置复制“发布网站”对话框。

Command for Publish Web Site with Default Settings

使用默认设置发布网站的命令

aspnet_compiler -nologo -v / -p "C:\WebSite1" -u "C:\TargetPath"

So you can do as following:

所以你可以这样做:

1) Read the above post and try to build a bat file with the compilation/publish command.

1)阅读上面的帖子并尝试使用compilation / publish命令构建bat文件。

2) Within that bat file, after compiling/publishin the website with the previous command, add the batch commands you want to execute.

2)在该bat文件中,在使用上一个命令编译/发布网站后,添加要执行的批处理命令。

Hope this helps you

希望这对你有所帮助

#1


1  

As this post states:

正如这篇文章所述:

The following command duplicates the Publish Web Site dialog with default settings.

以下命令使用默认设置复制“发布网站”对话框。

Command for Publish Web Site with Default Settings

使用默认设置发布网站的命令

aspnet_compiler -nologo -v / -p "C:\WebSite1" -u "C:\TargetPath"

So you can do as following:

所以你可以这样做:

1) Read the above post and try to build a bat file with the compilation/publish command.

1)阅读上面的帖子并尝试使用compilation / publish命令构建bat文件。

2) Within that bat file, after compiling/publishin the website with the previous command, add the batch commands you want to execute.

2)在该bat文件中,在使用上一个命令编译/发布网站后,添加要执行的批处理命令。

Hope this helps you

希望这对你有所帮助