1
votes

I am Building C# Application using Visual Studio Build In Azure Pipeline.

My solution Contains multiple project (ManagerWeb & WebAPI).

I want to Publish Two Separate Artifact ManagerWeb & WebAPI respectively.

enter image description here All the required File's are present in Build.ArtifactStagingDirectory.

How I can specify a pattern using which I can get Two Separate Artifact ? Example All the File name with WebAPI in 1st Artifact & ManagerWeb in another.

The File name from ArtifactStaging Directory are as Below

Something.Manager.WebAPI.deploy.cmd
Something.Manager.WebAPI.deploy-readme.txt
Something.Manager.WebAPI.SetParameters.xml
Something.Manager.WebAPI.SourceManifest.xml
Something.Manager.WebAPI.zip

Something.ManagerWeb.deploy.cmd
Something.ManagerWeb.deploy-readme.txt
Something.ManagerWeb.SetParameters.xml
Something.ManagerWeb.SourceManifest.xml
Something.ManagerWeb.zip

Any Help will be appreciable.

Thanks in Advance.

2

2 Answers

2
votes

Add a PowerShell task to create two folders and move the files to there:

cd $(Build.ArtifactStagingDirectory)
$files = dir
mkdir WebAPI
mkdir ManagerWeb
ForEach($file in $files)
{
   if($file.FullName.Contains("WebAPI"))
   {
       mv $file.FullName -Destination WebAPI
   }
   else
   {
       mv $file.FullName -Destination ManagerWeb
   }      
}

Then in the "Path to publish" field add the folders:

For WebApi artifacts:

$(Build.ArtifactStagingDirectory)/WebAPI

And for ManagerWeb artifacts:

$(Build.ArtifactStagingDirectory)/ManagerWeb
2
votes

Add two Copy Files steps which copy;

  • ManagerWeb files to $(Build.ArtifactStagingDirectory)\ManagerWeb
  • WebAPI files to $(Build.ArtifactStagingDirectory)\WebAPI

Then have two Publish Artifact steps to;

  • Publish $(Build.ArtifactStagingDirectory)\ManagerWeb as ManagerWeb
  • Publish $(Build.ArtifactStagingDirectory)\WebAPI as WebAPI

I've mocked this up and exported the YAML as follows;

pool:
  name: Hosted VS2017
steps:
- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)\ManagerWeb'
  inputs:
    SourceFolder: 'your/path/here/ManagerWeb'
    TargetFolder: '$(Build.ArtifactStagingDirectory)\ManagerWeb'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)\WebAPI'
  inputs:
    SourceFolder: 'your/path/here/WebAPI'
    TargetFolder: '$(Build.ArtifactStagingDirectory)\WebAPI'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: ManagerWeb'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)\ManagerWeb'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: WebAPI'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)\WebAPI'