Visual Studio生成事件后的Powershell脚本失败 [英] Powershell script from Visual Studio Post-build-event failing

查看:133
本文介绍了Visual Studio生成事件后的Powershell脚本失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中将Powershell脚本作为生成后事件运行失败,尽管该脚本可以从命令行正常运行。为什么会这样呢?



在我的情况下,问题是Windows 10 1903上的Visual Studio 2017 CE,症状是无法运行powershell脚本即使相同的Powershell以相同的特权从命令行运行时也没有错误,但仍会发生构建后事件。



我退出时出现了错误1,但可以看到脚本



VS使用的是32位版本(而不是根据问题的可接受答案使用的是64位版本),这就是我构建的Powershell



我运行PowerShell(x86)和Set-ExecutionPolicy Unrestricted,然后我的构建后任务运行正常。


Running a powershell script as a post-build event in Visual Studio fails despite the fact that that same script runs fine from the commandline. Why is this?

解决方案

Sorry for re-animating an ancient question but since my search lead me to this post and my resolution was slightly different I wanted to add it.

In my case the issue was with Visual Studio 2017 CE on Windows 10 1903 and the symptom was a failure to run a powershell script as a post-build event even though the same powershell ran without error from the command line with the same privileges.

I was getting an exited with error 1 but could see the script was not actually being run.

VS was using the 32 bit version (not the 64 as per the accepted answer to the question) and it was that build of powershell that I'd not set the exectution policy on.

I ran PowerShell (x86) and Set-ExecutionPolicy Unrestricted, then my post-build tasks ran fine.

这篇关于Visual Studio生成事件后的Powershell脚本失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆