0
votes

Here is my build pipeline:

pool:
  vmImage: 'macOS-latest'
  
variables:
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  displayName: 'Restoring nuget for the solution'
  inputs:
    restoreSolution: '**/*.sln'

- task: XamariniOS@2
  displayName: 'Building iOS for simulator'
  inputs:
    solutionFile: '**/*iOS*.csproj'
    configuration: '$(buildConfiguration)'
    buildForSimulator: true
    packageApp: false
- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
  inputs:
    SourceFolder: $(build.SourcesDirectory)
    Contents: '**/*.app'
    TargetFolder: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()
  
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: Mobile-BackReporting iOS'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()

The important part is task: CopyFiles@2

I am trying to copy the iOS simulator package i.e. SampleToDo.iOS.app to the staging directory. I can see that in build output, the file gets generated here:

/Users/runner/runners/2.171.1/work/1/s/MobileBackReporting.iOS/bin/iPhoneSimulator/Release/SampleToDo.iOS.app

To get to this path, I have tried all the possible combination of Build and Agent environment variable paths found here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

I still can't copy the SampleToDo.iOS.app file to staging area as copy file task gives warning as:

##[warning]Directory '/Users/runner/work/1/a' is empty. Nothing will be added to build artifact 'drop'.
##[warning]Directory '/Users/runner/work/1/s' is empty. Nothing will be added to build artifact 'drop'.
1

1 Answers

0
votes

If you enable system.debug (set system.debug=true variable in your pipeline) in your pipeline. You can see from the copy file task log, the .app is actually a directory. That is why the copy file task showed error that file was not found.

enter image description here

Since .app is a directory, you need to configure the copy file task like below. The copy file task will copy all the contents in this directory to folder $(build.artifactstagingdirectory)/SampleToDo.iOS.app.

If you want to generate .ipa file, you can set packageApp=true

    - task: CopyFiles@2
      displayName: 'Copy Files'
      inputs:
        SourceFolder: $(build.SourcesDirectory)
        Contents: '**/SampleToDo.iOS.app/**'
        TargetFolder: '$(build.artifactstagingdirectory)/SampleToDo.iOS.app'
        flattenFolders: true
      condition: succeededOrFailed()

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: Mobile-BackReporting iOS'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
      condition: succeededOrFailed()