6

I added some prebuild script to a Visual Studio 2017 project.

Pre-build script

powershell.exe -ExecutionPolicy ByPass -NoProfile -NonInteractive -File "./myscript.ps1"

It's just a script outputting some information in console.

The script executes correctly, whether it is launched directly in my Powershell console or from the build event (I can see the correct output in the Build Output panel in VS).


After the execution, the build fails with one error :

The "Exec" task was not given a value for the required parameter "Command"


I tried to reduce the problem to a minimal "./myscript.ps1" to show you my problem, and the problem occurs with any script, even an empty one!

And again, whatever the PS script is, it gives its output correctly.


Why does my build fail, and what can I do to fix it, while still running the script before build ?

Pac0
  • 21,465
  • 8
  • 65
  • 74
  • I'd very much like to know why I have been downvoted, for improvement / educational reasons. – Pac0 Mar 21 '18 at 09:07

1 Answers1

19

The issue was caused by this entry in the .csproj project file :

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
  <Exec Command="" />
</Target> 

Apparently, I (or VS ;) ) mistakenly added an empty script for PostBuild at the same time.

Removing the quoted entry solved the problem.

Thanks to Hans Passant's comment for pointing to the right direction.

Pac0
  • 21,465
  • 8
  • 65
  • 74
  • 1
    Thanks for this! In my case, I had an Exec tag whose Command was being cleared in order to prevent the post-build event from running during automation. I guess it doesn't like it being blank. So instead I set it to just print a quick statement saying the post-build was being skipped, and that worked! – inejwstine May 02 '19 at 15:50