TACO – Tools for Apache Cordova is a set of tools released by Microsoft for easing out the lives of hybrid mobile application developers. It comprises primarily Visual Studio tools for Apache Cordova – which is a part of the full blown Visual Studio 2015 IDE (for VS 2013 TACO is available as a VS Extension) that provides a lot of useful templates and features to do hybrid app development. The other part of TACO is the TACO-CLI. As the name suggests, this is the Command line counterpart of the VS extension, which helps in quickly bootstrapping apache cordova application. This works as a completely standalone CLI – meaning Visual Studio is NOT required to work with taco-cli. You can use any IDE of your choice to edit the projects you create using taco-cli.
Taco-cli is available as a part of npm (node package manager). So, installing this is as easy as running the npm command
npm install –g taco-cli
Available options with taco-cli :
Once the cli is installed, type the below command to see all the available options
taco help Project Commands: create .............. Create a new Cordova based TACO project templates ........... List available TACO templates for project creation kit ................. View or update details, about your Kit (Cordova CLI, platforms,and&nbsp;plugins) platform ............ Manage project platforms plugin .............. Manage Cordova plugins for the project install-reqs ........ Install platform-specific third-party dependencies required to build remote .............. Configure remote builds (currently supports iOS build only) build ............... Build the project for a given platform run ................. Run the project for a given platform on the selected device/emulator&nbsp;&nbsp; target emulate ............. Emulate a Cordova project General Commands: help ................ Get help for a TACO command docs ................ Open up the documentation page in your default browser version ............. Display the current TACO version feedback ............ Change feedback setting
One of the most important features that I loved about taco-cli are the taco-kit. Taco-kits make sure the cordova cli, platform, plugins that we use for a particular application are all 100 % compatible. As of this writing tacokits version 3.0.0 is the latest and that’s built on top of Cordova CLI 5.4.0. When you scaffold a new app using taco-cli, that will be created using taco kit 3.0.0 and will download all the platform/plugin related components that are compatible with cordova CLI 5.4.0
taco create DemoTacoApp ----------------------------------------------------------------------- Name ............. HelloTaco ID ............... io.taco.hellotaco Location ......... E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp Kit .............. firstname.lastname@example.org (Default) ------------------------------------------------------------------------ Creating a new cordova project. Success! Your project using the Blank template is ready for use at E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp
Another cool feature of taco-cli is the quick tips & commands it shows as we progress step by step. Since we just created a new app, we could see the next set of available actions for us under quick tips:
Quick tips & commands: * Change the directory to your project: cd E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp * Add a platform: taco platform add <PLATFORM> * Install the build tools for each platform: taco install-reqs <PLATFORM> * Add a Cordova plugin: taco plugin add <PLUGIN-ID> * Connect to a remote build agent: taco remote add <PLATFORM> * Build your app: taco build <PLATFORM> * Run your app in the emulator: taco emulate <PLATFORM> * Run your app on a device: taco run <PLATFORM></div> For command help, use 'taco help' For full documentation online, use 'taco docs'
Adding platform and building the app:
This is similar to Cordova cli commands.
taco platform add android taco build android taco emulate android
The emulate command will look for the default android emulator present in the machine.
Running the app in Visual Studio Emulator for Android:
Visual studio emulator for android – is the android emulator by Microsoft that ships with Visual Studio 2015. It is fast and it works on Hyper V. It also has a lot of cool features I am yet to explore more on. For now, we will see how to run the cordova app created using taco-cli in VS emulator.
- Open the Visual Studio Emulator
- Run the below command to make sure adb recognises the emulator
adb devices C:\WINDOWS\system32>adb devices List of devices attached 169.254.56.136:5555 device
The device listed is my instance of VS emulator. Note : For the above command to be successful, make sure the path of adb command is added to the PATH environment variable.
Now, running the below command will run the cordova app in VS emulator for android.
taco run android Running command: cmd "/s /c "E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\cordova\run.bat"" ANDROID_HOME=C:\Users\Swaminathan\AppData\Local\Android\android-sdk JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_79 WARNING : No target specified, deploying to device '169.254.56.136:5555'. ... BUILD SUCCESSFUL Total time: 4.24 secs Built the following apk(s): E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\build\outputs\apk\android-debug.apk Using apk: E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\build\outputs\apk\android-debug.apk Installing app on device... Launching application... LAUNCH SUCCESS
The other way to run in the emulator is using emulate command
taco emulate android --target "169.254.56.136:5555" Running command: cmd "/s /c "E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\cordova\run.bat --emulator --target=169.254.56.136:5555"" ANDROID_HOME=C:\Users\Swaminathan\AppData\Local\Android\android-sdk JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_79 Running: E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\gradlew cdvBuildDebug -b E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\build.gradle -PcdvBuildArch=x86 -Dorg.gradle.daemon=true ... BUILD SUCCESSFUL Total time: 12.629 secs Built the following apk(s): E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\build\outputs\apk\android-debug.apk Using apk: E:\Sambu\Project\TacoCliSamples\DemoTacoApp\DemoTacoApp\platforms\android\build\outputs\apk\android-debug.apk Installing app on device... Launching application... LAUNCH SUCCESS
Running the app first time might take a bit longer (even then it will definitely be lot faster than the stock android emulator) but the subsequent runs will be much faster as you could see 4.24 secs to build the application n launch the app in the emulator.
That’s about the very basics of getting started with taco-cli and running the Cordova application in VS Emulator.