visual-studio-2017 - 创建预构建事件后,得到错误 "The Exec task was not given a value for the required parameter Command"

标签 visual-studio-2017 post-build-event pre-build-event

我向 Visual Studio 2017 项目添加了一些预构建脚本。

Pre-build script

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/

相关文章:

windows-phone-7 - 尝试从命令行使用 MSBuild 来获取 WP7 解决方案

visual-studio-2015 - Visual Studio 2015 Tools for Apache Cordova 上的 PreBuildEvent 和 PostBuildEvent

c++ - 为什么 "if constexpr"不能用 Visual Studio 2017 15.3 编译?

python - Visual Studio 不使用当前的 PTVSD 版本

visual-studio - 从 Visual Studio 生成后事件访问 ProgramFilesFolder

visual-studio - VS2008 构建后事件批处理文件

c++ - 使用 CMake 在构建后运行 C++ 程序

jenkins - 有没有办法为 Jenkins 管道添加预构建步骤?

visual-studio - VS 2017 (Ctrl+R) 被按下。等待和弦的第二个键

visual-studio-2017 - VS2017 中的 "Initialize interactive with project"