0

I am working on Azure DevOps build pipeline. I have a Server.sln which has student 2 C# projects like Error.csproj and Log.csproj.

My folder structure is like below

Code (folder) 
   Error (folder) 
      Error.csproj
   Log (folder) 
      Log.csproj
   Server.sln

Staging (folder) 
 Error (folder) 
 Log (folder) 

I have Azure Pipeline which has a build task in debug mode which produces Error.dll in Error\bin\debug folder and Log.dll into Log\bin\debug folder. After that I want to copy Error.dll from Error\bin\debug into Staging\Error and Log.dll from Log\bin\debug folder into Staging\Log.

For this I am using 2 Copy file tasks.

One to copy Error.dll and other to do copy Log.dll.

Is it possible to combine this 2 copy tasks into one ?

Thanks in advance.

Ziggler
  • 3,361
  • 3
  • 43
  • 61
  • If your projects reference each other, the appropriate assemblies will be copied automatically. If they don't reference each other, there's no need for them to be in the same folder. Can you explain the problem in more detail? – Daniel Mann Apr 10 '19 at 21:47
  • Daniel... yes my Error project references Log project and in my Error\bin\debug I have Error.dll and Log.dll. I also thought about copy Error.dll and Log.dll from Error\Bin\debug. But I was trying to see whether I can copy Error.dll from Error\Debug\Bin and Log.dll from Log\Bin\Debug in one single Copy Files Task... multiple source path.... – Ziggler Apr 10 '19 at 22:25
  • Copy from the folder that has both. There's no reason to overcomplicate things. – Daniel Mann Apr 10 '19 at 22:33

1 Answers1

1

According your folders structure you can copy 2 files from 2 paths in this way (in YAML):

- task: CopyFiles@2
  displayName: 'Copy Error and Log dll's'
  inputs:
    SourcesFolder: '$(Build.SourcesDirectory)'
    Contents: |
     Code/Error/bin/Debug/Error.dll
     Code/Log/bin/Debug/Log.dll
    TargetFolder: '$(Build.ArtifactsStagingDirectory)' # Or different folder

But you can only copy to one target and in the target folder you will have all the folders that specified in the 'Contents':

- c:/agnet/_work/a/Code
                       - Error/bin/Debug/Error.dll
                       - Log/bin/Debug/Log.dll

If you want to copy to 2 folders (Error & Log in your case) or you want copy only the dll's (without the folders that contain them) you must use 2 copy tasks, or you can do the copy with PowerShell script and then you can use only 1 task.

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114