{"id":137,"date":"2020-06-09T18:51:04","date_gmt":"2020-06-09T17:51:04","guid":{"rendered":"https:\/\/archicode.azurewebsites.net\/?p=137"},"modified":"2020-06-09T18:51:04","modified_gmt":"2020-06-09T17:51:04","slug":"publish-a-xamarin-app-to-app-center-with-azure-pipeline","status":"publish","type":"post","link":"https:\/\/archicode.be\/index.php\/2020\/06\/09\/publish-a-xamarin-app-to-app-center-with-azure-pipeline\/","title":{"rendered":"Publish a Xamarin app to App Center with Azure Pipeline."},"content":{"rendered":"\n<p>I&#8217;ve been working on an android app with Xamarin lately and I wanted to deploy it to App Center automatically so I can install it on my mobile to test it as I hate manual deployment. <\/p>\n\n\n\n<p>I knew that App Center had a connector to azure devops repositories so you can build and deploy when a new commit arrives but I wanted to use Azure pipelines because there might be the need to deploy other things than the app. So after reading A LOT of documentation here and there here&#8217;s how I made it work.<\/p>\n\n\n\n<p>This tutorial assumes that you already have a Xamarin for android project created. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a keystore file with Android Studio<\/h2>\n\n\n\n<p>If you don&#8217;t have Android Studio yet, you can download it here :  <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/developer.android.com\/studio\/\" target=\"_blank\">https:\/\/developer.android.com\/studio\/<\/a> <br>Once in Android Studio, you need to create your keystore file by creating a new empty project, then go to <strong>Build <\/strong>in the menu and click on <strong>Generate Signed Bundle \/ APK<\/strong><br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image.png\" alt=\"\" class=\"wp-image-139\"\/><\/figure>\n\n\n\n<p>In the subsequent window, select the APK options<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-1-1024x692.png\" alt=\"\" class=\"wp-image-140\"\/><\/figure>\n\n\n\n<p>You need now to create the keystore by clicking on the &#8220;Create New&#8221; button under the keystore path<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-3.png\" alt=\"\" class=\"wp-image-142\"\/><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-2-1024x1018.png\" alt=\"\" class=\"wp-image-141\" width=\"317\" height=\"314\"\/><\/figure><\/div>\n\n\n\n<p>Then fill the next window.<br><strong>Key store path<\/strong> : the path where your file will be saved<br><strong>Password<\/strong> : Minimum 6 characters<br><strong>Alias<\/strong> : this is the name of the key you will use to sign your app<br><strong>Password<\/strong> : can be different that the keystore password<br><strong>Validity<\/strong> : I left it at 25 years, you can change it if you want.<\/p>\n\n\n\n<p>The rest of the window is self-explanatory, I have no idea if this influences in any way the behaviour of the key or the keystore but I&#8217;m guessing no.<br>You need to keep track of the informations you put in this window as we will need them later.<br>You can now close Android Studio as we won&#8217;t be needing it again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Get App Center Api key<\/h2>\n\n\n\n<p>In order to deploy from Azure Devops to App Center you need an Api key from App Center.  <br>You need go open<a href=\"https:\/\/appcenter.ms\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\"> App Center<\/a>, go to account settings in the menu under your avatar on the upper right corner.  In the following screen, scroll down until the <strong>User Api Key<\/strong> section, open it and click on the <strong>New API token<\/strong> button.  Enter the name of your key then select Full Access.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-11.png\" alt=\"\" class=\"wp-image-152\" width=\"230\" height=\"223\"\/><\/figure><\/div>\n\n\n\n<p>When you click the <strong>Add new API token<\/strong>, you will receive your API key.  Mind that it appears only once so make sure you save the key somewhere as you will need it afterwards.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copy the keystore file in Azure Devops<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-5.png\" alt=\"\" class=\"wp-image-144\" width=\"238\" height=\"190\"\/><\/figure><\/div>\n\n\n\n<p>In Azure devops there is a place where you can store securely any files you may need for your pipelines, it is called <strong>Secure Files<\/strong>.  You can access it in your Azure Devops environment under <strong>Pipelines <\/strong>> <strong>Library<\/strong>.<br><\/p>\n\n\n\n<p>You need to upload your keystore file here in order to access it in your pipeline<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-6-1024x254.png\" alt=\"\" class=\"wp-image-145\"\/><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-7.png\" alt=\"\" class=\"wp-image-146\" width=\"252\" height=\"75\"\/><\/figure><\/div>\n\n\n\n<p>You can also authorize all your pipelines to access the file.  But if you don&#8217;t, Azure Devops will ask you for permission when you will run your pipeline for the first time<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create the App Center connection<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-8.png\" alt=\"\" class=\"wp-image-147\" width=\"204\" height=\"236\"\/><\/figure><\/div>\n\n\n\n<p>In order to deploy your build to App Center, a connection between Azure Devops and App Center needs to be established.  To do so, open the project settings, and click on Service Connection.<br><\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-9.png\" alt=\"\" class=\"wp-image-148\" width=\"169\" height=\"126\"\/><\/figure><\/div>\n\n\n\n<p>Click on <strong>New Service Connection<\/strong>, choose the Visual Studio App Center, then Next<\/p>\n\n\n\n<p>This is where you use the Api key you got from App Center earlier.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/06\/image-10.png\" alt=\"\" class=\"wp-image-149\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">YAML<\/h2>\n\n\n\n<p>I decided to use YAML here instead of building my pipeline with the provided GUI because I wanted to see how functional it is and I must say I&#8217;m quite happy with it.  You include it in your repository and then you have your pipeline source controlled which is very nice.  When you have the Azure Pipeline extension installed in your Visual Studio Code, it gets easier.<br>This is my YAML file which is functional<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pool:\n  vmImage: 'VS2017-Win2016'\n\nvariables:\n  buildConfiguration: 'Debug'\n  outputDirectory: '$(build.binariesDirectory)\/$(buildConfiguration)'\n\nsteps:\n- task: NuGetToolInstaller@0\n\n- task: NuGetCommand@2\n  inputs:\n    restoreSolution: '**\/*.sln'\n\n- task: XamarinAndroid@1\n  inputs:\n    projectFile: '**\/*.csproj'\n    outputDirectory: '$(outputDirectory)'\n    configuration: '$(buildConfiguration)'\n\n- task: AndroidSigning@3\n  inputs:\n    apksign: true\n    apksignerKeystoreFile: 'Name of your file in Secure Files'\n    apksignerKeystorePassword: '$(password)'\n    apksignerKeystoreAlias: 'Name of the key specified in Android Studio'\n    apksignerKeyPassword: '$(keypassword)'\n    zipalign: false\n    apkFiles: '$(outputDirectory)\/*.apk'\n\n- task: PublishBuildArtifacts@1\n  inputs:\n    pathtoPublish: '$(outputDirectory)'\n\n- task: AppCenterDistribute@3\n  inputs:\n    serverEndpoint: 'Name of your App Center connection'\n    appSlug: 'AppCenterAccountName\/AppName'\n    appFile: '$(outputDirectory)\/*.apk'\n    symbolsOption: 'Android'\n    releaseNotesOption: 'input'\n    releaseNotesInput: 'Some message to give your users'\n    destinationType: 'groups'\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>It was quite an ordeal to find all the informations to finally be able to automatically deploy to App Center from Azure Devops with a sign APK.  If you are having any trouble with this present guide, don&#8217;t hesitate to contact me in the comment section or on twitter @Sisudev, I will gladly help you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working on an android app with Xamarin lately and I wanted to deploy it to App Center automatically so I can install it on my mobile to test it as I hate manual deployment. I knew that App Center had a connector to azure devops repositories so you can build and deploy when&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[5],"tags":[7,8,11,29],"class_list":["post-137","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-android","tag-app-center","tag-azure-devops","tag-xamarin"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":356,"url":"https:\/\/archicode.be\/index.php\/2024\/05\/09\/weird-issues-with-maui-blazor-hybrid-app\/","url_meta":{"origin":137,"position":0},"title":"Weird issues with Maui Blazor Hybrid app","author":"Hakim","date":"May 9, 2024","format":false,"excerpt":"Configuration Visual Studio 2022 17.8 .NET 8.0 Android SDK Steps Create a new \"Maui Blazor Hybrid Solution\" Try building the solution When you try building a Maui Blazor Hybrid Solution, in .NET 8, you might encounter a peculiar issue : Cannot deploy the solution, please select deploy in the Configuration\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":159,"url":"https:\/\/archicode.be\/index.php\/2020\/06\/24\/feature-flags-using-azure-feature\/","url_meta":{"origin":137,"position":1},"title":"Feature flags using Azure feature","author":"Hakim","date":"June 24, 2020","format":false,"excerpt":"Feature flags are very useful when you develop an application and while you don't want users to use the feature that isn't really ready, you don't want to stay on a side branch for too long as merging and rebasing from the main branch can become quite the chore. Enter\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":287,"url":"https:\/\/archicode.be\/index.php\/2023\/05\/28\/infrastructure-as-code-and-source-controle\/","url_meta":{"origin":137,"position":2},"title":"Infrastructure as Code and source controle","author":"Hakim","date":"May 28, 2023","format":false,"excerpt":"For those who don't what is this about, Infrastructure as Code is a set of files when executed with the right tool, will create resources such as storage account, databases, virtual network etc. It is mostly associated with the cloud. As I've been working lately with Terraform, I really enjoyed\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":368,"url":"https:\/\/archicode.be\/index.php\/2024\/05\/12\/error-netsdk1082-in-maui-blazor-hybrid-app\/","url_meta":{"origin":137,"position":3},"title":"Error NETSDK1082 in Maui Blazor Hybrid App","author":"Hakim","date":"May 12, 2024","format":false,"excerpt":"There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-x64' If you ever encountered this error in your Maui Blazor hybrid App, this is probably due to authentication.It took me a while to find it out (more than I care to admit) mainly because I had serial\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":20,"url":"https:\/\/archicode.be\/index.php\/2019\/02\/16\/esp8266-the-iot-prototyping-graal\/","url_meta":{"origin":137,"position":4},"title":"Esp8266 &#8211; the IOT prototyping Graal","author":"Hakim","date":"February 16, 2019","format":false,"excerpt":"1. A Esp-01 (the most basic of all the Esp8266) I've been working for some time now with IOT and I've worked extensively with the Esp8266 chip just because I'm testing a lot of stuff and don't want to spend a lot of money in it. You can get these\u2026","rel":"","context":"In &quot;IoT&quot;","block_context":{"text":"IoT","link":"https:\/\/archicode.be\/index.php\/category\/iot\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":162,"url":"https:\/\/archicode.be\/index.php\/2020\/06\/30\/blazor-server-side-or-web-assembly\/","url_meta":{"origin":137,"position":5},"title":"Blazor : server-side or Web assembly","author":"Hakim","date":"June 30, 2020","format":false,"excerpt":"Blazor is amazing. But if you are wondering which of Web Assembly of Server-Side would suit your project, here's an attempt to explain and help","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/archicode.be\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":0,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"wp:attachment":[{"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archicode.be\/index.php\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}