dansiegel / Mobile.BuildTools

The Mobile.BuildTools makes it easier to develop code bases in a clean, consistent, secure, and configurable way. Determine at Build which environment your app needs to run on, and what Client Secrets it should have. Plus many more amazing features!
http://mobilebuildtools.com
MIT License
228 stars 29 forks source link

AzureDevOps build "No value was provided for the Manifest" #281

Open Seuleuzeuh opened 3 years ago

Seuleuzeuh commented 3 years ago

Description

Hi @dansiegel, first of it, thanks for this awsome package 😸. I've a Xamarin.Forms App with an Android platform. I've implemented BuildTools on it, works perfectly on local machine (Windows & MacOS). But failed in an AzureDevOps pipeline.

Problems raised by the msbuild (full build log is attached) :

/Users/runner/.nuget/packages/mobile.buildtools/2.0.245/build/AndroidManifest.targets(28,5): warning : No value was provided for the Manifest. Unable to process Manifest Tokens

And

/Users/runner/.nuget/packages/mobile.buildtools/2.0.245/build/AndroidManifest.targets(48,5): error MSB4044: The "AutomaticBuildVersioningTask" task was not given a value for the required parameter "ManifestPath".

Thing to notice, the ImageResizerTask run succesfully.

Reproduction Steps

Don't know

Expected Behavior

Build in AZDevOps like in local machine

Actual Behavior

Build failed whith error MSB4044: The "AutomaticBuildVersioningTask" task was not given a value for the required parameter "ManifestPath"

Environment

Reproduction App

Part of my Yaml pipeline description :

 - task: NuGetAuthenticate@0

 - task: XamarinAndroid@1
   inputs:
     projectFile: '**/*Droid*.csproj'
     outputDirectory: '$(outputDirectory)'
     configuration: '$(buildConfiguration)'
     msbuildVersionOption: 'latest'
     msbuildArguments: ' /r /verbosity:diag /t:SignAndroidPackage /p:AndroidKeyStore="True" /p:AndroidSigningKeyStore="$(keystore.secureFilePath)" /p:AndroidSigningKeyPass="$(keystorePassword)" /p:AndroidSigningKeyAlias="$(keystoreAlias)" /p:AndroidSigningStorePass="$(keystorePassword)"'

I can share the full Yaml file if needed.

BuildLog.zip

buildBinLog.zip

dansiegel commented 3 years ago

It's really hard for me to make any determination here without having a binlog. If you can update the build step's msbuildArguments to include /bl and then publish the binlog on pipeline failure.

- task: NuGetAuthenticate@0

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*Droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
    msbuildVersionOption: 'latest'
    msbuildArguments: ' /r /bl /t:SignAndroidPackage /p:AndroidKeyStore="True" /p:AndroidSigningKeyStore="$(keystore.secureFilePath)" /p:AndroidSigningKeyPass="$(keystorePassword)" /p:AndroidSigningKeyAlias="$(keystoreAlias)" /p:AndroidSigningStorePass="$(keystorePassword)"'

- task: PublishPipelineArtifact@1
  displayName: 'Publish Binlog'
  condition: failed()
  inputs:
    artifactName: binlog
    targetPath: 'msbuild.binlog'
Seuleuzeuh commented 3 years ago

It's really hard for me to make any determination here without having a binlog. If you can update the build step's msbuildArguments to include /bl and then publish the binlog on pipeline failure.

- task: NuGetAuthenticate@0

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*Droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
    msbuildVersionOption: 'latest'
    msbuildArguments: ' /r /bl /t:SignAndroidPackage /p:AndroidKeyStore="True" /p:AndroidSigningKeyStore="$(keystore.secureFilePath)" /p:AndroidSigningKeyPass="$(keystorePassword)" /p:AndroidSigningKeyAlias="$(keystoreAlias)" /p:AndroidSigningStorePass="$(keystorePassword)"'

- task: PublishPipelineArtifact@1
  displayName: 'Publish Binlog'
  condition: failed()
  inputs:
    artifactName: binlog
    targetPath: 'msbuild.binlog'

Done, attached to the description. Sorry for the missing log.

dansiegel commented 3 years ago

@Seuleuzeuh the issue is being caused because the _GetAndroidPackageName task is not executing. Can you try replacing the XamarinAndroid task with:

- bash: |
    msbuild \
      ./src/ProjectName.Android/ProjectName.Android.csproj \
      /bl \
      /t:SignAndroidPackage \
      /p:Configuration=Release \
      /p:AndroidKeyStore=true \
      /p:AndroidSigningKeyStore=$KeystoreFile \
      /p:AndroidSigningStorePass=$KeystorePass \
      /p:AndroidSigningKeyAlias=$KeystoreAlias \
      /p:AndroidSigningKeyPass=$KeystorePass \
      /p:AndroidPackageFormat=aab \
      /p:OutputPath=$BuildOutputPath
Seuleuzeuh commented 3 years ago

@Seuleuzeuh the issue is being caused because the _GetAndroidPackageName task is not executing. Can you try replacing the XamarinAndroid task with:

- bash: |
    msbuild \
      ./src/ProjectName.Android/ProjectName.Android.csproj \
      /bl \
      /t:SignAndroidPackage \
      /p:Configuration=Release \
      /p:AndroidKeyStore=true \
      /p:AndroidSigningKeyStore=$KeystoreFile \
      /p:AndroidSigningStorePass=$KeystorePass \
      /p:AndroidSigningKeyAlias=$KeystoreAlias \
      /p:AndroidSigningKeyPass=$KeystorePass \
      /p:AndroidPackageFormat=aab \
      /p:OutputPath=$BuildOutputPath

Same result... Log attached build.binlog.zip BuildLog.zip

Seuleuzeuh commented 3 years ago

@dansiegel based on your "hack" proposed in this comment, i 've able to fix my build (partially). The Target _MBTGatherManifests was not launch because the target _GetAndroidPackageName was not listed :

The target "_GetAndroidPackageName" listed in an AfterTargets attribute at "/Users/runner/.nuget/packages/mobile.buildtools/2.0.245/build/AndroidManifest.targets (5,11)" does not exist in the project, and will be ignored.

So i've put this in a Directory.Build.props :

  <Target Name="MBTHack"
          BeforeTargets="HandleAndroidManifest"
          DependsOnTargets="_MBTGatherManifests">
  </Target>

Leading to a build succeed, and a correct generation of the AndroidManifest. The "partially" is for the final package who is misnamed : xAppId.xAppId.apk. I've try another target "hack" but was unable to succeed : the target _ValidateAndroidPackageProperties is run too soon, before the HandleAndroidManifest, so resulting in bad naming. But it's not a blocker.

Finally i think it's due to using a mac agent (i've don't try to use a windows one cause of some script in my yaml that are not compatible, if i have some time i'll try to test that) .

Seuleuzeuh commented 3 years ago

Finally i think it's due to using a mac agent (i've don't try to use a windows one cause of some script in my yaml that are not compatible, if i have some time i'll try to test that) .

I've made a rework of my build pipeline and made a job that run on windows for Android, and all work smoothly. So, on a mac agent it's not working properly, i was unable to make it work.