0
votes

PublishBuildArtifacts@1
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/publish-build-artifacts?view=azure-devops
Questions:
(1) What is the result of specifying artifactName? Its not clear from the docs. I see this in most of the examples, this becomes the sub-folder within the $(Build.ArtifactStagingDirectory) path. If I have additional tasks that build different parts of a solution containing several projects, can I specify another eg. 'drop2' or is this "drop" special?

(2) If using a private nuget feed, why must one also include a nuget.config file simply to reference the package ? The private feed is setup via a service connection in the azure project settings. Seems like you should be able to leave off

feedsToUse: 'config'
nugetConfigPath: 'Nuget.config'

(3) If I have several projects within a solution - eg. a .net core web app along with several class libs that target .net standard 2.x as well as a .net core console app, when is it better to use either of the tasks:
VSBuild@1 or DotNetCoreCLI@2
The end result of the build is I have two sub-folders in the output
drop & dropsrvc, which is exactly what I need. dropsvc has my service project in a zip file

I want to publish the .net core web app as a ready-to-copy folder in the release pipeline. I have this working, mostly by trial-and-error by re-purposing another build I did with a .net framework project, but now Im wondering if I should use the DotNetCoreCLI tasks?

So here is my yaml file. How would one replace the VS

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

#trigger:
#- dev

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  jobSrvProj: '**/myapp.sln.job/myapp.sln.JobSrv.csproj'
  reloWeb: '**/myapp.sln.Web/myapp.sln.Web.csproj'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Dev'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'config'
    nugetConfigPath: 'Nuget.config'
    externalFeedCredentials: 'Telerik nuget feed'


# web
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"  /p:UseWPP_CopyWebApplication=true  /p:OutDir="$(build.artifactstagingdirectory)" 
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'


# jobSrv
- task: VSBuild@1
  inputs:
    solution: '$(jobSrvProj)'
    msbuildArgs: '/p:OutputPath="$(Build.BinariesDirectory)\jobSrv-$(Build.BuildId)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

# jobSrv
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.BinariesDirectory)\jobSrv-$(Build.BuildId)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/jobSrv-$(Build.BuildId)/jobSrv-$(Build.BuildId).zip'
    replaceExistingArchive: true

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)\jobSrv-$(Build.BuildId)'
    ArtifactName: 'dropsrvc'
    publishLocation: 'Container'
1

1 Answers

1
votes
  1. It's the Artifact name you specify by yourself. Usually, you publish $(Build.ArtifactStagingDirectory) folder to DevOps. If you want to have multiple Artifacts, you could add multiple PublishBuildArtifacts task. For example:

enter image description here

enter image description here

  1. It's not must to include a nuget.config file in Nuget task. You can either select a feed from Azure Artifacts and/or NuGet.org here, or commit a nuget.config file to your source code repository and set its path here.

  2. VSBuild task build projects with MSBuild, while DotNetCoreCLI task build, test, package, or publish a dotnet application, or run a custom dotnet command. You could use VSBuild task to build .net framework projects, and use DotNetCoreCLI task build .net core projects in the same pipeline.