1
votes

I have a very simple pipeline yaml (see below)

What I am wanting is to build the projects in my solution, and retain the artifacts that get created so that I can release them to Azure in a separate release pipeline.

I recall doing something like this before, and when it worked I could see an option to view the build artifacts next to the successful build list item. However I see no such thing anymore.

What am I missing here?

Pipeline:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    zipAfterPublish: true
5

5 Answers

3
votes

You may add something like that (copy to artifact folder and publish):

- task: CopyFiles@2
       displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
       inputs:
       SourceFolder: '$(system.defaultworkingdirectory)'
       Contents: '**\bin\$(BuildConfiguration)\**'
       TargetFolder: '$(build.artifactstagingdirectory)'
       condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
       displayName: 'Publish Artifact: drop'
       inputs:
       PathtoPublish: '$(build.artifactstagingdirectory)'
       condition: succeededOrFailed()
1
votes

You have to publish your Build Artifact, use this task:

Publish Artifact

After that you can check your Artifacts under Summary:

Artifact

1
votes

Try to add CopyFiles task and PublishBuildArtifacts task:

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'config'
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    zipAfterPublish: true

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(agent.builddirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

enter image description here

1
votes

I based my answer by ms documentation ( all details are available https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops ).

There are three tasks based on DotNetCoreCLI (restore, build and publish to correct dir) and last task that publish artifact to the feed.

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: build
    projects: '**/*.csproj'
    arguments: '--configuration $(buildConfiguration)' # Update this to match your need

- task: DotNetCoreCLI@2
  displayName: Package
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.

- task: PublishBuildArtifacts@1
  displayName: "Publish as artifact"
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'myWebsiteName'
0
votes

The answer I was looking for to find my artifacts online is to add /_build to the end of the url for my App in Azure DevOps or visualstudio.com

example: https://your-company.visualstudio.com/Your-App/_build