Some men want to watch the build fail

How to fix “MSB4044: The AndroidSignPackage task was not given a value for the required parameter KeyPass

2 min read.

This article explains a quick fix to an error along the lines of “AndroidSignPackage” task was not given a value for the required parameter “KeyPass”. In my case the issue occurred in a GitHub Actions pipeline, but you could get it in Azure DevOps or even when running the build command locally.

Problem

So when you’re trying to publish an Android package, either locally or in a pipeline, you’ll get an error like this:

error MSB4044: The "AndroidSignPackage" task was not given a value for the required parameter "KeyPass".

MSB4044 doesn’t help us much – it’s a pretty generic error message, covering all cases where msbuild is given a task but not the right parameters. But the parameter name should be a pretty good pointer.

Reason

I could only find one result on Google, a Stack Overflow discussion that had the wrong answer. So I guess documenting the fix is the least I could do :)

In the Azure DevOps YAML pipeline, said user was using the MSBuild task. The same issue can arise from a task in a GitHub Actions pipeline as well, and probably even when you’re running MSBuild locally.

The root cause – probably – is an Android publish task requiring both a keystore AND the password to it. That password is something you’ve set when creating the keystore, but your command or task is missing it.

Solution

If you’re really trying to configure an Android build, you’ll need to supply the password. If you’re NOT building for Android, you’ll need to make sure you’re not targeting Android (targetFramework maui-android – for example).

The steps below should describe how to fix the issue.

Time needed: 2 minutes

Fixing “MSB4044: The AndroidSignPackage task was not given a value for the required parameter KeyPass”

  1. If you’re NOT building for Android, exclude Android-specific stuff

    Make sure your .csproj -file has all of the Android-specific stuff wrapped in a Condition that excludes them if you’re not building for Android. Something like below:

    <PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">

  2. Don’t try to use MSBuild task or some other nonsense like that. Just run everything in a PowerShell script or something.

    In GitHub Actions, this’ll look somewhat like this:

    - name: Publish MAUI Android
    run: dotnet publish -f:net7.0-android -c:Release /p:AndroidSigningKeyPass=${{secrets.keystorepassword}} /p:AndroidSigningStorePass=${{secrets.keystorepassword}}


    (This sample presumes you’ve stored your keystore password in Repository Secrets.

  3. (OPTIONAL) Just fill your password in the .csproj file

    I wouldn’t recommend this – but if you want to be able to publish without remembering the password, and you KNOW you’re only running this locally without committing your .csproj file – sure, why not fill it in the file directly. I guess it should work, and if you’re ever just running stuff locally, you won’t need to deal with any extra complicatedness.

    <PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">
    <AndroidKeyStore>True</AndroidKeyStore>
    <AndroidSigningKeyStore>myapp.keystore</AndroidSigningKeyStore>
    <AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
    <AndroidSigningKeyPass>mypass</AndroidSigningKeyPass>
    <AndroidSigningStorePass>mypass</AndroidSigningStorePass>
    </PropertyGroup>

And that should be it.

mm
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments