Hello Jim Jupiter ,
Welcome to Microsoft Q&A forum.
Error code 9009 do indicate the command is not recognized. We can know that after typeing a PowerShell command in build events, VS calls cmd.exe
to execute it. In your case, it seems that cmd.exe
can't recognize a PS command(including Line breaks) and throw error.
Please remove line breaks and write the command on one line.
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -Command "Write-Host 'Hello from PowerShell!'"
Then copy and past to Pre-Build event filed.(To make it easier to read, you can click on Word-wrap )
Test result comparing: Failed
Succussed
got error "The command '$content/parts/major' is either misspelled or could not be found."
Please try modify them like the following: Adding this content "This is a Pre Build Test" in build.txt for test.
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Command "$content = Get-Content 'build.txt'; $parts = $content -split ' '; $major = $parts[0]; $patch = $parts[2] ;$build = $parts[3] + 1;$content;$parts;$major;$patch;$build"
Best Regards, Dou
If the answer is helpful, please click "Accept Answer" and upvote it. Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.