-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET MAUI Android target publishing/archiving #4377
Comments
I updated my original comment. For making it work with .NET MAUI Blazor app see here: #2246 (comment) This should be working out-of-the-box from the next preview |
I'm curious, why do you need to run We have MSBuild properties for configuring signing: These are the same in Xamarin.Android and .NET 6. It seems like you could just use: <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>filename.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>keystore.filename password</AndroidSigningStorePass>
<AndroidSigningKeyAlias>keystore.alias</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>keystore.alias password</AndroidSigningKeyPass>
</PropertyGroup Then you just |
Updated in initial comment above. |
Sorry i'm not very familiari with these procedures, is "keystore.filename" correct or should be "filename.keystore"? |
@Ghevi whoops! I will fix that now, however not that this is not a fixed value. This should be the password that corresponds to your keystore file :) Maybe this video I made about it makes things more clear as well: https://www.youtube.com/watch?v=jfSVb_RR7X0 |
Setting |
We want to do a build on Azure DevOps to Binaries directory by specifying |
Here is the binary log of MAUI project for @xperiandri's scenario |
Could you please give an example of the full command that you are trying to run? |
Also tried with |
I think this is a problem in the dotnet CLI tooling and not so much with us: dotnet/sdk#9012 As suggested in the linked issue, would you be able to try |
Do I understand right that this parameter doesn't support explicit paths? As I remember, I have already tried it and it didn't come up with me, because I wanted a command for the pipeline in Azure DevOps to specify an explicit path to folders so I used |
I checked locally another variant, parameters |
If it works locally but not on Azure DevOps then there must be something different in these environments. Does it run the |
@Juriyx this example works for me with MAUI Preview 14:
Then I have these files in test:
I tried a folder with spaces, but that works for me as well. If it's failing, can you add |
Yes. It is OS - macOS 11 on Azure DevOps and Windows 10 locally. But I tried windows-2019 and it doesn't change the situation.
I need to explain. There are 3 main folders when building Azure pipeline - sources (s), build (b) and artifacts (a). Sources contain repository files, build logically should contain files from build and artifacts - package files, copied from build folder. But instead of this everything goes into sources by default. So the main question is: When using "publish", which correct parameters should I use to specify the folder for build and the output folder for artifacts? |
@Juriyx it sounds like you need to share a sample project with this problem. You are setting MSBuild properties like Is a |
Yes, I set them to custom locations (/p:OutDir and /p:PublishDir)
I will check it in DevOps. Locally the same problem appeared but I investigated that it was a mistake in letters in the wrong keyboard layout. After the fix, it worked as expected. |
Hi. I tested the clean template in the console locally and the publishing path didn't work. Here is the binlog: |
@Juriyx is this problem happening because this is an "incremental build"?
Then later this target isn't finding any output files: What should be happening here is any Are you doing a |
@jonathanpeppers we call |
So these were my steps that worked before:
You're doing the same? |
This seems to work for me, too...
|
No, because as we explained we want to have binaries in |
We have common projects for backend and mobile that can be versioned themself and mobile and server parts that are versioned themself. |
Is there an alternative to Like |
I think we have established that this works and we have official docs now for it. So closing this one for now. If you have any specific issues with publishing, please open an issue for that. Thanks everyone for the input! |
TL;DR
Description
I have been trying to see if publishing an Android app through .NET MAUI works at the moment. This description assumes that you have basic knowledge of publishing to the Google Play Store.
1. Prerequisites
AndroidManifest.xml
file contains a valid version number and package identifier (i.e.com.mycompany.app
)2. Create keystore file
This process is no different between Xamarin, Xamarin.Forms, .NET MAUI or even a native app. Run the following command to create a new keystore file. If you already have an existing keystore file, you can skip this step.
Make sure you know where you're running this command from so you know where the keystore is created. Alternatively, provide a full path for the
-keystore
option.keytool -genkey -v -keystore key.keystore -alias key -keyalg RSA -keysize 2048 -validity 10000
Make note of the value in
-alias
this can be anything, but you will need it later. You will also need to provide a password. Needless to say, you will need that one and need to remember it as well. For detailed instructions, see this existing Docs page.3. Update your csproj file
We need to add the information we got from above into our csproj file. If you have an existing app, you can potentially copy this from your Android csproj file. The information will look like this, and needs to be contained within the
<Project></Project>
node.This information will only be added if you are building the Android target and building the release configuration. Tweak this as needed.
I think all the info speaks for itself, add the path to your keystore file along with the alias and corresponding passwords.
4. Build your .NET MAUI Android app
Navigate to the folder that holds the source for your .NET MAUI Android app and execute the following command:
dotnet publish -f:net6.0-android -c:Release
This will create a couple of files under the
bin\Release\net6.0-android\publish
folder. There should be a file that will have the name of your package identifier and that mentions "-Signed". For example, look for:com.mycompany.app-Signed.aab
.For the Google Play Store you will need the aab file, for other purposes you can use the apk file that is also in there.
Notes
dotnet publish
command. E.g.<AndroidSigningKeyPass>mypassword</AndroidSigningKeyPass>
would become/p:AndroidSigningKeyPass=mypassword
.Related Resources
Also See
The text was updated successfully, but these errors were encountered: