我有一个脚本,它可以解压MVC包,缩小所有CSS和js文件,然后重新打包。在我的机器上以及作为管理员或TeamCity账户在CI服务器上运行时都能完美工作。但是当TeamCity拉取并运行它时,脚本会输出所有预期的内容,没有报错,但它永远不会解压文件。
write-host "creating shell object"
$shell_app=new-object -com shell.application
write-host "creating zip file"
$zip_file = $shell_app.namespace("C:\temp\PokerLeagueWebSite.zip")
write-host "setting folder to unzip to"
$destination = $shell_app.namespace("C:\temp\zy98")
write-host "about to copy files from zip"
$destination.Copyhere($zip_file.items(), 0x4)
write-host "finished"
以下是TeamCity的输出结果:
[23:01:03]: Step 5/5: test ps1 file (Powershell)
[23:01:03]: [Step 5/5] Starting: C:\Windows\system32\cmd.exe /c
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -File
C:\TeamCity\buildAgent\work\71e78d4c543e0594\Tools\test.ps1 && exit /b %ERRORLEVEL%
[23:01:03]: [Step 5/5] in directory: C:\TeamCity\buildAgent\work\71e78d4c543e0594
[23:01:03]: [Step 5/5] creating shell object
[23:01:03]: [Step 5/5] creating zip file
[23:01:03]: [Step 5/5] setting folder to unzip to
[23:01:03]: [Step 5/5] about to copy files from zip
[23:01:03]: [Step 5/5] finished
[23:01:03]: [Step 5/5] Process exited with code 0
[23:01:03]: Publishing internal artifacts
[23:01:03]: [Publishing internal artifacts] Sending build.finish.properties.gz file
[23:01:03]: Build finished
如果我在TeamCity账户上的服务器上运行相同的命令,它将正常工作:
C:\Windows\system32\cmd.exe /c C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -File C:\TeamCity\buildAgent\work\71e78d4c543e0594\Tools\test.ps1 && exit /b %ERRORLEVEL%
我只能想到这可能是TeamCity正在做某些事情,或者与其作为服务运行有关,但我被难住了,无法解决这个问题。