来自 Visual Studio 后构建事件失败的 Powershell 脚本 [英] Powershell script from Visual Studio Post-build-event failing

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

问题描述

在 Visual Studio 中将 powershell 脚本作为构建后事件运行失败,尽管该脚本在命令行中运行良好.这是为什么?

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.

在我的情况下,问题出在 Windows 10 1903 上的 Visual Studio 2017 CE,症状是无法将 powershell 脚本作为构建后事件运行,即使相同的 powershell 从命令行运行时没有错误权限.

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.

我退出时出现错误 1,但可以看到脚本实际上并未运行.

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

VS 使用的是 32 位版本(不是 64 位,根据问题的已接受答案),而且我没有设置执行策略的正是 powershell 版本.

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.

我运行了 PowerShell (x86) 和 Set-ExecutionPolicy Unrestricted,然后我的构建后任务运行良好.

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

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

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