@sppc42 has the right answer, but some details that took me a minute to find:
- task: DotNetCoreCLI@2
displayName: 'dotnet build lib project only'
inputs:
projects: '**/*.csproj'
arguments: '/p:ContinuousIntegrationBuild=true -c $(BuildConfig)'
workingDirectory: '$(System.DefaultWorkingDirectory)' <<< I had a sub-dir here, AND in classic GUI pipelines, this is auto-collapsed and easy to miss!