相关疑难解决方法(0)

如何在VS 2012中的Web部署发布任务之前执行PowerShell脚本?

目前,我使用Visual Studio 2012在我的Web项目中配置了一个构建后事件,如下所示:

在此输入图像描述

这基本上调用PowerShell脚本向每个.cs文件添加版权声明.

我想要做的是仅在将Web应用程序发布到远程服务器之前执行此PowerShell脚本.这样做我每次需要调试项目时都不会遇到延迟.你知道有什么方法可以实现吗?


根据Sayed的回答,我定制了一个特定的发布配置文件并添加了这个:

<PipelineDependsOn>
  CustomBeforePublish;
  $(PipelineDependsOn);
</PipelineDependsOn>
</PropertyGroup>
<Target Name="CustomBeforePublish">
<Message Text="******* CustomBeforePublish *******" Importance="high" />
<Exec Command="powershell.exe -file &quot;$(ProjectDir)\Copyright.ps1&quot;" />
</Target>
Run Code Online (Sandbox Code Playgroud)

powershell publish msdeploy post-build-event visual-studio-2012

19
推荐指数
2
解决办法
7761
查看次数