I'm trying to publish a new nuget package but my pipeline is failing on the Pack stage with the following warning and error,
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1
##[error]An error occurred while trying to pack the files.
the nuspec file
<?xml version="1.0"?><package ><metadata><id>ExamplePackage</id><version>$version$</version><title>ExamplePackage</title><authors>Test</authors><owners>Test</owners><icon>icon.png</icon><requireLicenseAcceptance>false</requireLicenseAcceptance><description>somethign</description><releaseNotes>Initial</releaseNotes><copyright>Copyright 2020</copyright><tags>xyz</tags><dependencies><group targetFramework=".NET6.0"><dependency id="Newtonsoft.Json" version="12.0.3" exclude="Build,Analyzers" /></group></dependencies><contentFiles><files include="bin\Release\netcoreapp3.1\ExamplePackage.xml" buildAction="content" flatten="true" copyToOutput="true"/></contentFiles></metadata><files><file src="bin\Release\netcoreapp3.1\*.dll" target="lib\netcoreapp3.1\"/><file src="icon.png" target="" /><file src="bin\Release\netcoreapp3.1\ExamplePackage.xml" target="lib\netcoreapp3.1" /></files></package>
And the yaml file is pointing to a deployed template file. The Pack stage (the stage where it fails) of that template file is shared below,
# Perform .Net 6 Pack - task: DotNetCoreCLI@2 inputs: command: 'pack' packagesToPack: '${{ parameters.repository_title }}/src/${{ parameters.project_title }}/${{ parameters.project_title }}.csproj' nobuild: true packDirectory: '$(Pipeline.Workspace)/nuget' versioningScheme: 'byEnvVar' versionEnvVar: 'nextRelease' displayName: Pack name: 'pack' condition: and(succeeded(), ne(variables['nextRelease'], ''))