Create a Signed and Publishable .NET MAUI Android App in VS2022

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so you've created this amazing.net value app and now you want to publish to the store but you're not sure exactly how to do it in this video i'm going to show you exactly that how to create a keystore how to create a app that is publishable to the google play store so stay tuned so the process of archiving and publishing your app to the store is generally the same across windows mac os ios and android you all have to have this certificate or some way to digitally sign your binary that you're going to deliver to the store because that will prove that you created this app version now that's important because if someone a person that is not as nice as you maybe finds the credentials for your publisher account maybe they have access to your code somehow but you know you have that certificate which is still very much private somewhere you kept that in a safe they can't find that so that still prevents them from uploading a app to the store right because they could create a version that would get all kind of user data from your users from your app that is not something that you should want so this is kind of like an extra layer of security um so that they can't just upload any version to the store because it's not signed by you now for android this happens with a key store and that key store you only have to generate it once basically but you don't have to lose it well you should not lose it because if you lose it then you won't have any way of uploading new versions of your app to the google play store so whenever you've generated that key store you have to hold on to it because if you lose it you will have to create another definition in the google play store and you will have to supply your app to that but you can't update the existing listing in the google play store so you can just generate a new key store that's no problem i'm going to show you how to do that in this video but you have to keep it if you have generated one and if you have published it to the store because the first time you publish it to the google play store then the key store is attached to that app and you have to keep using that key store over and over again for each update that you're going to provide to the google play store so that is very important now let's switch over to visual studio you can see here visual studio 2022 now the interesting thing is that i'm going to show you everything in the command line how to do it which first of all teaches you you know how to do the actual stuff what is going on under the hood and secondly the ui just isn't there in visual studio yet um so at the time of recording visual studio and dotted maui is still in preview but i promise you this process is going to be exactly the same whenever dotnet maui is released i also promise you there will be a ui in visual studio to do this just like there is today for xamarin forms but it just isn't ready yet because of all the changes that we're going through but a big bonus is if you've learned how to do it through the command line then you also know how to incorporate this in your build pipeline and ultimately that is where you want to deliver your versions from to the google play store right so without further ado let's just check out how to do this um so here we are in visual studio 2022 the preview version right now and the app doesn't really matter you can substitute this with your own amazing app of course that you have written this is just the file new new.net maui application that you're seeing here so just a default template which doesn't really matter i'm not even going to show you it to you but i can just use this to make a publishable version for the store now what we want to do is go into a terminal i can do that by pressing control back tick or you can find it here in view terminal and that will pop up a terminal that's integrated right into visual studio which is pretty pretty amazing this is powershell in this case you can also get like the the windows command line doesn't really matter and if you can run kind of like your android app for dotnet maui then you have all the tools installed to also create the keystore and and do all the commands that i'm showing you here today now also if you already have a key store because you're going to update an existing app with this major upgrade to done at maui and your user won't notice a thing from that but you can still sign it with the same key store that you already have but if you're going to publish a new app then you need to create the keystore and i'm going to show you that right now so what you need to do is go through the key tool and you need to supply a whole bunch of parameters here so some of them are going to be kind of like generic you just have to use them other ones is values that you have to come up with and we're going to use that in a little bit to actually generate our signed binary so pay attention so we're going to use key tool then we're going to say gen key minus v i'm definitely not even sure what this all means but this is how you should do it and then you're going to say key store so this is going to be where the key store is going to be stored i'm just going to say key dot keystore which is the file name with the extension and it's just going to save it in like this folder right here so the c users and the folder that i'm running this project from so it's just going to save it there we'll see that in a little bit then we're going to say alias that's important too that's kind of the alias inside of this keystore i think technically you might have more aliases in one key store i don't really know so but this alias is a name that you should remember so save that somewhere in your password manager or whatnot somewhere where you feel it's safe but you're going to need this alias later on so i'm just going to name this maui alias and then the next couple of things is the key algorithm so you can specify an algorithm with which the the keystore the the encrypted data will be signed and we're just going to say rsa then we're going to say key size which is has to do with how many bytes are being used for like the encryption and stuff uh 2048 and this last part is kind of interesting as well and also very important so we can specify the validity which i'm going to set to 10 000 which is a number of days so 10 000 days which sounds like pretty much and you always want to have your certificates kind of like expire very quickly right that's more secure but the funny thing is whenever you provide a signed binary to the google play store and the validity isn't long enough then it will say i can't do this i can't take in this thing you need to make it expire much more in the future because if we think back to what i just told you if your key store is expired then you can't do updates so you need to set this to a very high number a number where you're confident that that will be the end of life of your app because whenever this keystore expires that's also the point where you can stop updating your app in the google play store so you have to make sure that this is a big number so that it doesn't expire in the lifetime of your application now with this i can just press enter and it's going to ask me a couple of things it's going to be kind of like this command line wizard so first i have to do a password i'm just going to do i don't know maybe subscribe now maybe something that you want to subscribe to i need to re-enter this so subscribe now and then you have to supply a couple of values like your first and your last name well that one is easy uh what is the name of your organizational unit to be honest i don't even know what they want here and i think you have to specify at least one of these values the rest doesn't really matter or you can just you know type some garble in there i don't know so my organizational unit oh you i don't know name of your organization i work with microsoft i don't know you know netherlands that's where i am so just do some things here and then you have to pay attention because then it's going to ask you to confirm here at the bottom and then you have to say yes or no and the default is no so whenever you just press enter here the whole thing starts over so make sure that you press yes here and it's going to do some things generating key pair self signed certificate uh with a validity of 10 000 days and then you have to enter a separate password for the alias here which is the maui alias and you can just press return for like the same password so it's going to be subscribed now as well if you want you can do a different password here which makes it even more secure for now i'm just going to press return and we have the same thing it's going to give you this warning to be honest i don't think it doesn't really mean anything probably it's good to look into that but at least you know this format that we have generated right now is the one that is accepted by the google play store and i'm not sure if this is going to be accepted so this warning this this key tool is something is a java tool not as much as an android tool i think so you know it might give you a warning for something completely different now if we do explorer dot which will open the file explorer in windows we can also see that that key store is now here so you want to grab this one you definitely do not want to commit this to your public repository um you probably want to keep this in a safe place so that others can't get to it because this is the key to publishing your app to the store so beware of that i'm just going to keep it here so i can close this terminal right now because we've actually gone through the hard part and i'm going to go to my solution explorer and then open the cs proj right here now as you know dotted maui has this single project approach so all the targets android ios mac catalyst windows they're all here in this project which is really convenient for developing but for you know publishing these kinds of things you really have to do some platform specific stuff so that makes it a little bit harder but it's still very very easy to do now don't be scared i'm going to paste in some some xml from right here off screen and i will walk you through that so what this does if you've looked into cs product files before these property groups can have a condition so this property group is only added to your build whenever the target framework has android which kind of makes sense right we only want to do this for android bills else it might even give you some some error if you don't add this and the configuration is released so we only have to actually sign our binary whenever we create a release build right so you know you can tweak this if that's necessary for your requirements but um this kind of like makes the most sense for most people i think now android keystore we're going to set that to true android signing key store is going to be dot slash key dot key store because if you think back to the file explorer then the keystore was actually at the same level as the solution file and the cs profile is a level deeper so we have to have this relative path of course you know if you have the keystore somewhere different or you pull it in through some kind of build step in your pipeline and then you want to provide this value elsewhere but or another way but this definitely works as well you can just put the path in here now we are going to have this signing store pass and that was subscribe now so we have that the alias i set that to maui alias right so here's where the alias comes in and then i have the same password right here and now we actually have everything in place to create a signed app so actually i'm going to well i could set it here to release and i could do a build and that will give me a binary that will actually work that will actually be signed that you can actually take from actually let me do that so i'm just gonna build this right here i'm going to say right click build and that should create a release build so the build is starting and then in our output folder there will be a aab file because that is the only accepted format by now for the google play store the android app bundle and you can just take that and you can upload that to the store no questions asked but if we want to continue down with the terminal path right here so we're going to go to view terminal again you can also do another thing so i can also say dot net publish and i have to specify the configuration so dash c which is going to be released right before we need to trigger this configuration part right here so release and if you're doing this through the command line then you also need to specify the target framework so we're going to say dash f and then we're going to have to say net 6.0 android which is kind of like the target that you can see here all the way at the top right so we have these targets in our single platform a single project approach right here so and if we scroll down it's also needed because we need to trigger this target framework contains dash android right and that is what it does right here so and if we do this um then we kind of like have the same thing as whenever we just build the application and it will be in our output folder but now it will be in a separate publish folder but it will do the exact same thing in fact you could also do net build minus c release minus f net 6.0 android you will have the exact same things okay so the command line returned so we should have binaries right now let's do another explorer dot to open our file explorer right here and we're going to go into our maui publishing sample app right here the bin folder the release folder the android folder and here you can already see two aab files and an apk file the apk file is still generated maybe you can disable that somehow i don't think you can use it to go through the store anymore you can still sign load that on your android device probably but for the google play store you need the aab file right now and you need to have the one that had signed in it right so the dash signed that is the one that is actually signed that you can upload to the play store that you can release and that you can um distribute to your users yay now the exact same thing basically is in this publish folder so that's kind of like the difference between a.netbuildin.net publish you know it's up to you which command you want to use in which scenario but here you have the same thing so we have the the regular a b maybe you have some use for the not signed one you want to sign it with a different key store you can do that manually if you want but you want to basically take this signed one and you can upload that to the google play store one other thing that i want to tell you um which can be important whenever you want to run this from a automated pipeline um especially like with the keystore file right if you're going to pull down that from a secure storage or something like that you can also provide these values that you're here putting in the cs proj file you can put that as parameter in your net publish command so if we go back to the dot net publish right here we can also specify the values of of these things right here like namely like this key store i can just copy this and i can say slash p and i can say android signing key store is and then i with quotes if needed i can provide the actually let me get myself out of the way i can provide the value here as a command line argument as well so you can put it here in quotes if there's some kind of space in there but technically you don't really need to do that and if we look at like the other properties you can specify all the properties or you can mix and match so if i go to the android signing store pass right here that's probably one that you don't want to have in the cs proj you can just add that here as a command line variable as well and you could just add the password this way so this is just another way of also supplying these values which does the exact same thing you don't need to have both in there but you know if it suits your scenario better then you can also provide it here through the command line and run it like that and had that is how you can archive and publish your dot net maui android app now that wasn't too bad right i mean yes there is some manual work that you need to do here but mostly the stuff that you need to do just once and ideally in your pipeline so that you can just get that binary at the end of your pipeline as an artifact and you can send that right away to the google play store and then you have your app launched and you will get rich loaded with the success of your million dollar app of course now you're probably wondering and how about my don at maui ios app well this video right here will show you how to do this for ios but maybe you still need to build your whole app and you could use map with that then maybe you should check out this playlist on all the things dotnet maui and of course you want to make sure that you check here to subscribe to my channel and all of this content will come to you automatically see you next time [Music]
Info
Channel: Gerald Versluis
Views: 27,163
Rating: undefined out of 5
Keywords: publish app to google play, google play store, publish app on play store, dotnet maui aab, dotnet maui publish app, dotnet maui tutorial, .NET MAUI, .NET MAUI tutorial, .NET MAUI apk, How to generate signed aab file, how to generate signed apk for google play, how to generate signed apk in visual studio, how to generate signed bundle or apk, android keystore, android keystore explained, android keystore generate, aab file android, dotnet maui android, VS2022
Id: jfSVb_RR7X0
Channel Id: undefined
Length: 16min 12sec (972 seconds)
Published: Mon Feb 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.