NuGet pack Unable to cast object of type 'System.String' to type 'NuGet.Frameworks.NuGetFramework
Came across a rather misleading error message above today while attempting to pack and publish a .Net Standard class library project to a private feed as a DevOps Artifact.
Well, it turns out that the NuGet Pack and NuGet Push are not supported by NuGet 4.x at this time. The workaround is to use the .Net core specific build tasks which include commands for pack and publish as show below:

Came across a rather misleading error message above today while attempting to pack and publish a .Net Standard class library project to a private feed as a DevOps Artifact.
Well, it turns out that the NuGet Pack and NuGet Push are not supported by NuGet 4.x at this time. The workaround is to use the .Net core specific build tasks which include commands for pack and publish as show below:
YAML
-(PACK)
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: pack
packagesToPack: <your project.csproj>
versioningScheme: byPrereleaseNumber
-(PUSH)
steps:
- task: DotNetCoreCLI@2
displayName: 'dotnet push'
inputs:
command: push
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!
$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
publishVstsFeed: '<your feed id>'
The other interesting point to note is that the NuGet Restore works just fine in version 4.x. for .Net Core and .Net Standard pipeline tasks respectively.
One to watch out for until the NuGet team enhances support for the other frameworks.

If you would like some hands on expertise for your business feel free to reach via my company assemblysoft or checkout some other musings via my blazor.net and azure blog here carlrandall.net
Reference Articles
https://github.com/NuGet/Home/issues/4808