title: How can I save screenshots and videos as attachments in Azure Build Pipeline with TestCafe and Yaml?
body: <p>I am trying to create a build pipeline in Azure Devops that</p>
  <ol>
  <li>runs tests created in TestCafe Studio</li>
  <li>Saves screenshots on error, and saves videos of every test</li>
  <li>Saves videos of the test runs</li>
  <li>Publishes the results of the testing to Test Runs</li>
  <li>Publishes the screenshots and videos as attachments to both the rest results in the build pipeline and in the resulting test runs</li>
  </ol>
  <p>For the life of me, neither me, nor my team can figure out how to do that - we are currently in a state of saving test runs, and saving videos and screenshots as artifacts, but none of them are attached to the test results in either the builds or test runs - here is an example of one of our YAML files</p>
  <pre><code># ASP.NET
  # Build and test ASP.NET projects.
  # Add steps that publish symbols, save build artifacts, deploy, and more:
  # https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
  
  trigger:
  - master
  
  pool:
    vmImage: 'windows-latest'
  
  variables:
    solution: '**/*.sln'
    buildPlatform: 'Any CPU'
    buildConfiguration: 'Release'
  
  steps:
  - task: NuGetToolInstaller@1
  
  - task: NuGetCommand@2
    inputs:
      restoreSolution: '$(solution)'
  
  - task: VSBuild@1
    inputs:
      solution: '$(solution)'
      msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=&quot;$(build.artifactStagingDirectory)&quot;'
      platform: '$(buildPlatform)'
      configuration: '$(buildConfiguration)'
  
  - task: VSTest@2
    inputs:
      platform: '$(buildPlatform)'
      configuration: '$(buildConfiguration)'
  
  - task: NodeTool@0
    inputs:
      # Replace '10.14' with the latest Node.js LTS version
      versionSpec: '10.14'
    displayName: 'Install Node.js'
  
  - script: npm install -g testcafe testcafe-reporter-xunit
    displayName: 'Install TestCafe'
  
  - script: npm install --save @ffmpeg-installer/ffmpeg
    displayName : Install FFMpeg
  
  - script: npm install testcafe-reporter-nunit3
    displayName: Install NUnit
  
  - script: testcafe chrome **/Tests/**/* -S -s takeOnFails=true --video --reporter spec,xunit:report.xml
    displayName: Run tests - Save screenshots and videos
    continueOnError: true 
  
  - task: PublishTestResults@2
    displayName: Publish test results
    continueOnError: true
    inputs:
      testResultsFiles: '**/report.xml'
      searchFolder: $(System.DefaultWorkingDirectory)
      testResultsFormat: 'NUnit'
      publishRunAttachments: true
      testRunTitle: &quot;Task Results&quot;
      failTaskOnFailedTests: false
  
  - task: CopyFiles@2
    inputs:
      sourceFolder: '$(Build.SourcesDirectory)'
      contents: '**/?(*0.png|*1.png|*2.png|*3.png|*4.png|*5.png|*6.png|*7.png|*8.png|*9.png|*.mp4)'
      targetFolder: '$(Build.ArtifactStagingDirectory)'
  
  - task: PublishBuildArtifacts@1
    inputs:
      pathToPublish: '$(Build.ArtifactStagingDirectory)'
      artifactName: Saved failure screenshots
  </code></pre>
  <p>There seems to be some obvious step that we're missing, but none of us can find it, and after exhaustive searches none of us can find a solution.  What are we missing?</p>