在预构建事件或 post 构建事件中请求用户输入 - Visual Studio

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

我希望用户通过请求用户输入来批准预构建事件或 post 构建事件中的操作 - 例如 'y' 或 'n'。因此,如果用户忘记切换配置,例如,用户可以取消任务。

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

有人可以给我举个例子吗?不幸的是,我找不到任何东西。如果可能的话,我想避免调用另一个批处理文件。 提前致谢。

在构建事件命令 window 中使用 "start /wait" 启动您的命令。

示例:

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

然后您可以使用 Read-Host 请求用户输入。