我向 Visual Studio 2017 项目添加了一些预构建脚本。
powershell.exe -ExecutionPolicy ByPass -NoProfile -NonInteractive -File "./myscript.ps1"
它只是一个在控制台输出一些信息的脚本。
脚本正确执行,无论是直接在我的 Powershell 控制台中启动还是从构建事件启动(我可以在 VS 的构建输出面板中看到正确的输出)。
执行后,构建失败并出现一个错误:
The "Exec" task was not given a value for the required parameter "Command"
我试图将问题减少到最小的“./myscript.ps1”以向您展示我的问题,并且任何脚本都会出现问题,即使是空脚本!
再说一次,无论 PS 脚本是什么,它都能正确输出。
为什么我的构建失败,我能做些什么来修复它,同时在构建之前仍然运行脚本?
最佳答案
该问题是由 .csproj
中的这个条目引起的。项目文件:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="" />
</Target>
显然,我(或 VS ;) )同时错误地为 PostBuild 添加了一个空脚本。
删除引用的条目解决了问题。
感谢 Hans Passant 指出正确方向的评论。
关于visual-studio-2017 - 创建预构建事件后,得到错误 "The Exec task was not given a value for the required parameter Command",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49237261/