'Visual Studio: Run a post build event in the background
I have a powershell script that I want to run when the post-build event is triggered in Visual Studio. However, it is important that the script runs in the background and does not pause the build process while it is running. The other requirement is that I must be able to pass in the project directory with spaces in the directory name.
I have been having trouble getting both to happen at the same time. After much trial and error, I have found a complex solution to running a powershell script in the background, but it doesn't work with spaces in the directory name. Here is what I am currently doing, but I am quite open to something completely different as this seems overly complicated:
In the post-build event in Visual Studio:
powershell -ExecutionPolicy Unrestricted start-process " $(ProjectDir)scripts\post-build.cmd" -ArgumentList $(TargetDir),$(ConfigurationName),$(ProjectDir)
And here is the post-build.cmd:
START /B CMD /C CALL "Powershell.exe" -ExecutionPolicy Unrestricted -file %3scripts\post-build.ps1 %1 %2 %3
I have tried just adding quotes around the arguments, but I keep getting various errors (i.e. missing terminator '"') from Powershell when I do so.
Please forgive my ignorance, I am new to Powershell and Visual Studio.
Solution 1:[1]
You can run a Powershell script directly from within a post build event. For example, I’ve done that to digitally sign an executable after the build completes. Here’s the command line I used in my post build step:
powershell.exe -file "$(SolutionDir)sign.ps1" "$(TargetPath)" "..\..\installs\certs\DigitalSignature.pfx"
Notice that there's no need to use a batch file.
Solution 2:[2]
Twilio developer evangelist here.
Currently the Twilio API does not support the context field with information about message replies. The parameters that Twilio does support are listed in the documentation here and are ProfileName, WaId (WhatsApp ID, typically a phone number), Forwarded, FrequentlyForwarded, ButtonText (if using quick reply buttons), and, when receiving location messages, Latitude, Longitude, Address, and Label.
These parameters are updated as we increase our support for the WhatsApp API, so check back regularly or keep an eye on the changelog for updates.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rrirower |
| Solution 2 | philnash |
