0
votes

So I've got a solution with multiple .NET projects in it.

Solution1 contains Solution1/Project1 Solution1/Project2 Solution1/Project3

Every project's has multiple underlying folders and files that need to be in the same structure.

I'm automating the deployment with Azure Devops. When the solution is being build by the azure DevOps it copy's the files to the StagingDirectory and there it creates a package. When I open this package every file is being copied to the package but there are no folders and there is no structure. How can I setup the build that it's separates every solution to it's own folder. I can't figure this out.

Many thanks in advance.

Project structure

enter image description here

1

1 Answers

0
votes

You can use multiple instances of the "Copy Files" task to define the folder structure of your artifact. Using a combination of the "Source Folder", "Contents" (allows for filtering of files) and "Target Folder" properties, you can create a structure that works for you. Just be careful not to check the "Clean Target Folder" or "Flatten Folders" options else you'll potentially risk losing some of the structure you're after.

Something along the lines of:

"Source Folder" = "Solution"
"Contents" = "**/Scripts/**/*.*"
"Target Folder" = "$(Build.ArtifactStagingDirectory)/Scripts"

"Source Folder" = "Solution"
"Contents" = "**/*_GLOBAL/**/*.*"
"Target Folder" = "$(Build.ArtifactStagingDirectory)/Global"

"Source Folder" = "Solution"
"Contents" = "**/*_REPORTING/**/*.*"
"Target Folder" = "$(Build.ArtifactStagingDirectory)/Reporting"

Should give you:

  Artifact
    - Scripts
      - Script 1
      - Script 2
      ...
    - Global
      - Global.exe
      ...
    - Reporting
      - Reporting.exe
      ...

Although by tweaking the parameters above you should be able to achieve what you're after, I would suggest that if you're solution contains multiple projects that individually achieve different aims, then you might want to look at splitting them out into separate solutions (_REPORTING) and pulling in common funtionality (_GLOBAL?) using NuGet or similar.