AfterPublish script doesn't run when I publish a web app

前端 未结 2 1247
醉酒成梦
醉酒成梦 2020-12-11 02:54

I\'ve got an ASP.NET web app that I publish to our website when I make changes or fix bugs. We want to automatically save a backup of the project files to our server (separ

2条回答
  •  醉梦人生
    2020-12-11 03:24

    When you run the cmd file manually, the script surely runs with administrator privileges, or enough privileges to succesfully copy the files to the destination (in the I: unit in this case).

    The thread that executes the script from Visual Studio probably has very restricted privileges, due to security reasons.

    Your best bet, is run the script from powershell, passing the following argument to it:

    -ExecutionPolicy Unrestricted

    Your XML will look like this:

    
      
         
          %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
        
        
          C:\deg\bat\backupRMA.cmd
        
      
        
    
    

    You can also check this MSDN link for similar commands:

    http://www.asp.net/web-forms/tutorials/deployment/advanced-enterprise-web-deployment/running-windows-powershell-scripts-from-msbuild-project-files

提交回复
热议问题