Move a Xamarin Android native app from VS2022 to VSCode

177 Views Asked by At

I developed an Android native app (not xamarin forms) with Visual Studio 2022 until recently (and the iOS version on XCode) on an old mac with Intel chip. To be able to continue developing for iOS I've been moved to a new mac with M1 chip, but without Visual Studio for Mac, only XCode and VSCode. The coding, signing, distribute things were nice and easy with VS2022 but become a nightmare with Visual Studio Code on my new mac.

By chance, my admin installed JDK and allowed me to have rights to execute Android command-line tools, so, i was able to install an Android SDK.

I am able to build the Android App Bundle (AAB) within a launch.json and a tasks.json files under vscode. I'm able to sign the AAB manually (in a terminal). so, yet, the signed AAB can be uploaded to Google Play Console. But, I'd love to use vscode as an IDE more than a vi editor deluxe.

First, as the msbuild shell execution generate a com.company.application.aab file and a com.company.application-Signed.aab i'd like to specify another keystore than the "default" one.

my launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Build - Droid Release",
            "type": "mono",
            "preLaunchTask": "run-release-android",
            "request": "attach",
            "address": "localhost",
            "port": 10000
        },
        {
            "name": "Build - Droid Debug",
            "type": "mono",
            "preLaunchTask": "run-debug-android",
            "request": "attach",
            "address": "localhost",
            "port": 10000
        },
        {
            "name": "Attach - Droid debug",
            "type": "mono",
            "request": "attach",
            "address": "localhost",
            "port": 10000
        },
        {
            "name": "Run - Droid debug",
            "type": "xamarin",
            "request": "launch",
            "packageName": "com.company.application"
          }
    ]
}

My tasks.json :

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "run-debug-android",
            "command": "msbuild",
            "type": "shell",
            "args": [
                //"-t:Run",
                "${workspaceFolder}/Droid/MMR.Droid.csproj",
                "-p:TargetFramework=net6.0-android",
                "-p:Configuration=Debug",
                "-p:AndroidAttachDebugger=true",
                "-p:AndroidSdbHostPort=10000",
                "-t:Install"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "run-release-android",
            "command": "msbuild",
            "type": "shell",
            "args": [
                //"-t:Run",
                "${workspaceFolder}/Droid/MMR.Droid.csproj",
                "-p:TargetFramework=net6.0-android",
                "-p:Configuration=Release",
                "-p:AndroidAttachDebugger=false",
                "-p:AndroidSdbHostPort=10000",
                "-t:Install"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

during the msbuild process, i can see : /Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/bin/jarsigner -keystore "/Users/username/.local/share/Xamarin/Mono for Android/debug.keystore" -storepass android -keypass android -digestalg SHA-256 -sigalg SHA256withRSA -signedjar bin/Release/com.company.application-Signed.aab obj/Release/android/bin/com.company.application.aab androiddebugkey

1/ How to specify a different keyStore location/file ?

I cannot use Flutter, gradle at this time. I even have no "brew" installed, and no rights to install it. I haven't told it, but no Android Studio neither.

I thought about a workload MAUI and convert the project into MAUI (hopefully later) but of course, no rights to install workload.

At least, I have the following extensions for vscode installed :

  • .NET Intall Tool
  • .NET MAUI
  • ADB Interface for VSCode
  • C#
  • C# Dev Kit
  • Remote repositories
  • Mono Debug
  • Xamarin Debug

If I really need to install something else which require higher privilege, I'll have to justify it.

Thank you for all the hints and tips.

0

There are 0 best solutions below