Visual studio 使批处理命令等待,直到它在模拟器上构建Visual Studio解决方案/部署Android应用程序
使用批处理脚本,我在模拟器上部署了一个XamarinAndroid应用程序。命令工作正常,但它不等待部署操作的结果,而是执行下一个命令,而不等待部署操作的结果。我需要根据部署成功与否采取行动。我尝试了以下代码:Visual studio 使批处理命令等待,直到它在模拟器上构建Visual Studio解决方案/部署Android应用程序,visual-studio,batch-file,Visual Studio,Batch File,使用批处理脚本,我在模拟器上部署了一个XamarinAndroid应用程序。命令工作正常,但它不等待部署操作的结果,而是执行下一个命令,而不等待部署操作的结果。我需要根据部署成功与否采取行动。我尝试了以下代码: ::Build the solution "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" /run release "C:\Users\xxxxx.sln" :WAITLOOP i
::Build the solution
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" /run release "C:\Users\xxxxx.sln"
:WAITLOOP
if "%ERRORLEVEL%"=="0" goto RUNNING
goto NOTRUNNING
:RUNNING
goto WAITLOOP
:NOTRUNNING
::Next statements
但这段代码是在无限循环中运行的。关于谁生成批处理脚本的任何建议,请等到生成结果出来后再执行下一条语句。您需要使用/build not/run以不按打开IDE
start”“/WAIT”“\devenv.com”“
?并在命令提示窗口中运行if/?
,以获取显示的命令帮助,如果该命令已在顶部解释了Microsoft支持文章中更详细的if errorlevel Number命令语法。在这里,如果errorlevel 1转到NOTRUNNING(不运行)
,使用就足够了。感谢@Bernhard的回复,但是Visual studio不会在刚构建的基础上创建apk文件,我们需要运行项目才能创建apk文件。和run命令打开带有解决方案的IDE并运行应用程序,但它不会等到完成部署。
::Build the solution
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" /build "C:\Users\xxxxx.sln"
if "%ERRORLEVEL%"=="0" goto ok
echo Did not compile correctly
goto end
:ok
::Next statements
:end