microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.42k stars 2.58k forks source link

[Question]: can I set signingOptionForExport alone with signingOption #19640

Open ExerciseBook opened 3 months ago

ExerciseBook commented 3 months ago

Task name

XcodeV5

Task version

236

Environment type (Please select at least one enviroment where you face this issue)

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

MacOS 13

Question

for some strange reason, my project can only build with signingOption = default, but if I need to archive it, I must provisioningProfiles in the export plist.

reproduce this situation:

  1. create a blank unity project
variables:
  - group: TestProject

  - name: System.Debug
    value: true

trigger:
  - main

jobs:
  - job: ExportXcodeProject
    pool:
      vmImage: "ubuntu-latest"
    steps:
      - checkout: self
        path: s/TestProject

      - task: Cache@2
        inputs:
          key: "Library-iOS"
          path: "$(Agent.BuildDirectory)/s/TestProject/Library"

      - script: bash "scripts/ios-build/prepare.sh"
        env:
          AGENT_BUILDDIRECTORY: $(Agent.BuildDirectory)
        # git clone https://github.com/game-ci/unity-builder.git --depth=1 $AGENT_BUILDDIRECTORY/s/unity-builder

      - script: tree $(Agent.BuildDirectory)

      - script: bash "scripts/ios-build/run-unity-ci.sh"
        retryCountOnTaskFailure: 3
        env:
          AGENT_BUILDDIRECTORY: $(Agent.BuildDirectory)
          UNITY_EMAIL: $(TestProject.UnityEmail)
          UNITY_PASSWORD: $(TestProject.UnityPassword)
          UNITY_SERIAL: $(TestProject.UnitySerial)
        # #!/bin/bash
        # set -x
        # 
        # VERSION=$(git describe --tags `git rev-list --tags --max-count=1` | sed 's/^v//;s/-.*//')
        # 
        # ANDROID_VERSION_CODE=$(date +"%y%m%d")00
        # 
        # echo "VERSION = $VERSION"
        # 
        # echo "ANDROID_VERSION_CODE = $ANDROID_VERSION_CODE"
        # 
        # docker run \
        #     --rm  \
        #     --env UNITY_EMAIL=$UNITY_EMAIL \
        #     --env UNITY_PASSWORD=$UNITY_PASSWORD \
        #     --env UNITY_SERIAL=$UNITY_SERIAL \
        #     --env UNITY_VERSION=2022.3.20f1 \
        #     --env PROJECT_PATH=. \
        #     --env BUILD_TARGET=iOS \
        #     --env BUILD_NAME=iOS \
        #     --env BUILD_PATH=build/iOS \
        #     --env BUILD_FILE=iOS \
        #     --env VERSION=$VERSION \
        #     --env ANDROID_VERSION_CODE=$ANDROID_VERSION_CODE \
        #     --env ANDROID_EXPORT_TYPE=androidPackage \
        #     --env ANDROID_SYMBOL_TYPE=none \
        #     --env GIT_CONFIG_EXTENSIONS \
        #     --env GITHUB_WORKSPACE=/github/workspace \
        #     --volume $AGENT_BUILDDIRECTORY:/root:z \
        #     --volume $AGENT_BUILDDIRECTORY/s/Milthm:/github/workspace:z \
        #     --volume $AGENT_BUILDDIRECTORY/s/unity-builder/dist/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z \
        #     --volume $AGENT_BUILDDIRECTORY/s/unity-builder/dist/platforms/ubuntu/steps:/steps:z \
        #     --volume $AGENT_BUILDDIRECTORY/s/unity-builder/dist/default-build-script:/UnityBuilderAction:z \
        #     unityci/editor:ubuntu-2022.3.20f1-ios-3.0.1 \
        #     /bin/bash -c /entrypoint.sh

      - task: PublishPipelineArtifact@1
        inputs:
          targetPath: "$(Agent.BuildDirectory)/s/TestProject/build"
          publishLocation: "pipeline"
          artifactName: "XcodeProject"

  - job: XcodeBuild
    dependsOn: ExportXcodeProject
    pool:
      vmImage: "macos-13"
    steps:
      # - checkout: self
      #   path: s/TestProject

      - checkout: none

      - task: DownloadPipelineArtifact@2
        inputs:
          artifact: "XcodeProject"
          path: "$(Agent.BuildDirectory)/s/TestProject/build"

      # - script: cargo install tre-command

      # - script: tre $(Agent.BuildDirectory)

      - script: cat $(Agent.BuildDirectory)/s/TestProject/build/iOS/iOS/Unity-iPhone.xcodeproj/project.pbxproj

      - task: InstallAppleCertificate@2
        displayName: "Install AppleCert"
        inputs:
          certSecureFile: "AppleCert.p12"
          certPwd: "$(TestProject.AppleDistributionCertificatePassword)"
          keychain: temp

      - task: InstallAppleProvisioningProfile@1
        displayName: "Install mobileprovision"
        inputs:
          provisioningProfileLocation: 'secureFiles'
          provProfileSecureFile: "SOMETHING.mobileprovision"
          removeProfile: true

      - task: Xcode@5
        inputs:
          actions: "build"
          exportPath: "output/package"
          archivePath: "output/archive"
          xcodeVersion: "specifyPath"
          xcodeDeveloperDir: "/Applications/Xcode_15.2.app/Contents/Developer"
          sdk: "iphoneos"
          xcWorkspacePath: "$(Agent.BuildDirectory)/s/TestProject/build/iOS/iOS/Unity-iPhone.xcodeproj"
          configuration: "Release"
          scheme: "Unity-iPhone"
          cwd: "$(Agent.BuildDirectory)/s/TestProject/build/iOS/iOS/"
          useXcpretty: false
          signingOption: 'default'  # my problem
          signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
          provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
          teamId: "$(TestProject.AppleTeamId)"
          packageApp: true
          exportOptions: "auto"  # my problem

I can not set PROVISIONING_PROFILE or PROVISIONING_PROFILE_SPECIFIER during the build step because there are two targets in the exported xcode project, and one of them needs a sign, but the other doesn't.

and I need to set signingOptionForExport because if I need to archive the app, singing is required.

DmitriiBobreshev commented 3 months ago

Hi @ExerciseBook, thanks for the question, as I see from sources when you choose the "signingOption" as 'default' you still can manage signingOptionForExport and set it to manual with exportOptions: "auto".

When signingOptionForExport is default we determine the signing using ".pbxproj" file. The file itself we looking it here and in the file itself we're looking for the ProvisioningStyle manual string. In that case, "provisioningProfiles" will be added in your export plist

ExerciseBook commented 3 months ago

yes you are right,

we can see that, the provisioningProfiles will add only when signingOptionForExport === 'manual')

https://github.com/microsoft/azure-pipelines-tasks/blob/609873a3cf6a8730806cad3e7d873686799a8c98/Tasks/XcodeV5/xcode.ts#L439

but signingOptionForExport depend on signingOption

https://github.com/microsoft/azure-pipelines-tasks/blob/609873a3cf6a8730806cad3e7d873686799a8c98/Tasks/XcodeV5/xcode.ts#L428

so I have no idea about setting the provisioningProfiles for archive.

finally, I work around by setting a plist file

image

I am not very sure if it is a desire to add a separate task input for setting signingOptionForExport strategy