0
votes

Been stuck on this for days... need help with my YAML file in a Azure Devops Pipeline. I upgraded to .NET 5 and now my Universal Packages are not being properly built.

Background:

I created a new project in Azure Devops and configured a regular Pipeline and a Release Pipeline. The initial (regular) pipeline does not package the proper Universal package. I tested it by downloaded the files using Azure CL and there are no zip files in it.

Following is my YAML file:

# ASP.NET Core (.NET Framework)
# Builds and publishes a new version of each project in the solution as a nuget package in the Artifacts Feed

name : 5.1$(Rev:.r)

# TRIGGER WHEN WE CHECK IN CODE
trigger:
- master

# RUN THIS PIPELINE IN WINDOWS
pool:
  vmImage: 'windows-latest'

# USE THESE VARIABLES
variables:
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  universal: 'artifact.web' # the name of the Universal package in the Artifacts feeds

# PERFORM THESE STEPS USING NUGET & MSBUILD: 
# 1. RESTORE from nuget
# 2. BUILD solution
# 3. PACK nuget packages
# 4. PUSH packages to Artifacts feed
# 5. Create the Universal Artifacts 

steps:
- task: UseDotNet@2
  inputs:
    version: '5.0.x'
    includePreviewVersions: true # Required for preview versions
    
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1
    checkLatest: true

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'ae385ab4-48a5-4c76-b207-dfd1050b8ebf/4b05f135-0b1d-48ad-a8e6-d26bf03c2aae' 
    
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    arguments: '--configuration $(buildConfiguration)'
  displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: '**/*.csproj'
    versioningScheme: 'byEnvVar'
    versionEnvVar: 'Build.BuildNumber'
    includesymbols: true 

- task: NuGetCommand@2
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: 'ae385ab4-48a5-4c76-b207-dfd1050b8ebf/4b05f135-0b1d-48ad-a8e6-d26bf03c2aae'
    allowPackageConflicts: true

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Build.ArtifactStagingDirectory)'
    publishLocation: 'pipeline'


- task: UniversalPackages@0
  displayName: Universal Publish
  inputs:
    command: publish
    publishDirectory: '$(Build.ArtifactStagingDirectory)'
    vstsFeedPublish: 'ae385ab4-48a5-4c76-b207-dfd1050b8ebf/4b05f135-0b1d-48ad-a8e6-d26bf03c2aae'
    vstsFeedPackagePublish: '$(universal)' # the name of the Universal package in the Artifacts feeds
    packagePublishDescription: '$(universal)'

The pipeline completes successfully but the zip files that represent the Universal package are not created.

When I run the Release Pipeline, I get this error:

##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

Any idea how to build a proper Universal file in Azure Devops Pipelines?

2
Please show your YAML file before PublishPipelineArtifactKrzysztof Madej
Added my YAML file - thanks @KrzysztofMadejMecaMatt
Please check whether my answer can help you. If not, please provide a configuration example of the task of getting the package in your release pipeline so that people can better investigate this question.Jane Ma-MSFT

2 Answers

1
votes

I tried your code and successfully downloaded the package in the release pipeline.

enter image description here

It may be that the path you took to get the package in release pipeline was wrong, not that the package was not generated.

You can use the Universal Package task to download the package and see if it is successful.

If so, please check the task you download the package. Universal packages are not stored as zip files. If you get the package as zip, it will most likely fail. In addition, you can click on the artifact in the build log to see if your path is correct.

enter image description here

enter image description here

As shown in the picture: The path of the dotnetcore.5.1.2.nupkg file should be D:\a\r1\a\Job\dotnetcore.5.1.2.nupkg.

0
votes

The issue was with not using the most up to date version of Nuget.

Added this to my YAML

- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 5.8.0'
  inputs:
    versionSpec: 5.8.0