Reputation: 46
I’m building a xamarin android app using visual studio community edition 2019 on windows. Inside visual studio gui I am able to build and deploy to android emulator. I’m willing to do this without using the gui, through command line . I understand msbuild can build. May I know the command to start the emulator and deploy the app?
Upvotes: 1
Views: 4437
Reputation: 5109
Steps to Build & Deploy to Android through the command line (replace Sample
with your project name):
msbuild Sample.Android/Sample.Android.csproj /verbosity:normal /t:Rebuild /t:PackageForAndroid /t:SignAndroidPackage /p:Configuration=Debug
cd Sample.Android/bin/Debug
to find the the signed APK file,adb install com.tfp.sample-Signed.apk
, explained here.I have written a more detailed explanation over here.
Upvotes: 2
Reputation: 46
I'm a beginner batch scrip writer. So feel free to correct this:). This scripts work for me to build the xamarin visual studio project, start the emulator and deploy the apk. I have two batch files, the second one runs in parallel with the first one.
cmd.bat:
"C:\Program Files\Android\android-sdk\platform-tools\adb.exe" start-server
"C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Debug /p:Platform="any cpu" /v:m "E:\App2\App2.sln"
@echo off
if %ERRORLEVEL%% == 0 (
start /min call "E:\App2\Build Commands\install.bat" ""
"C:\Program Files\Android\android-sdk\emulator\emulator.EXE" -no-boot-anim -avd lollypop -prop monodroid.avdname=lollypop
exit
) else (
pause
)
install.bat:
"C:\Program Files\Android\android-sdk\platform-tools\adb.exe" wait-for-device
"C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" -r /t:Install /v:m "E:\App2\App2.Android\App2.Android.csproj" /p:AdbTarget=-e
@echo off
if %ERRORLEVEL% == 0 exit else pause
Upvotes: 0