Copy Files to: $(Build.ArtifactStagingDirectory) -Input required: TargetFolder

6k views Asked by At

I am new to YAML and build pipelines. I am receiving the following error, can anyone advice what's wrong with the target folder.

Unhandled: Input required: TargetFolder

[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.

Below is my YAML file:

# Build app using Azure Pipelines

pool:
  vmImage: 'vs2017-win2016'

steps:
- script: echo hello world
- task: NodeTool@0
  inputs:
    versionSpec: '8.x'

- task: CopyFiles@1
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(build.sourcesdirectory)'
    Contents:
     \C:\VSCodeGit\CollMod.Web\Web.config\
    TartgetFolder: '$(Build.ArtifactStagingDirectory)'
  condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
  condition: succeededOrFailed()
2

There are 2 answers

0
Colin B On BEST ANSWER

I think it's the contents field that looks to be invalid here.

The docs at https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=vsts&tabs=yaml and further documentation on https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/file-matching-patterns?view=vsts which both give some great examples.

If you're unsure set the contents to **/* which will copy absolutely everything in the $(build.sourcesdirectory), but it will give you a feel for the shape of the directory structure so that you can change **/* into something more selective and scoped for the file(s) you want to copy.

0
Jbeat On

The Source folder should be : Build.SourcesDirectory instead of '$(build.sourcesdirectory)'

This is from : https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables