visual-studiouser-inputpost-build-eventpre-build-eventbuild-events

Request user input in pre or post build event - Visual Studio


I want the user to approve an action in the pre or post build event by requesting an user input - like 'y' or 'n'. Thereby the user can cancel the task if he forgot to switch the Configuration by mistake for example.

if $(ConfigurationName) == Release (
   //ask user to type in some text
)

Can someone provide me an example? Unfortunately, I couldn't find anything. If possible I would like to avoid calling another batch file. Thx in advance.


Solution

  • Initiate your command in the build event command window with "start /wait".

    Example:

    start /wait powershell.exe -file $(ProjectDir)\UpdateAssemblyVersion.ps1 -configuration $(ConfigurationName)
    

    Then you can request user input by using Read-Host.