I added caching of nuget in the CI Pipeline,
https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/caching-nuget?view=azure-devops
and therefore needed the files packages.lock.json in the root of all projects, leading to the error
"C:\hostedtoolcache\windows\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: D:\a\1\s[PROJECT1]\packages.lock.json, D:\a\1\s[PROJECT2]\packages.lock.json ...."
Thus exluding the files from output folder didn't change the error and build failure.
The following worked : ErrorOnDuplicatePublishOutputFiles>false
<PropertyGroup>
<!-- creates nuget lock file packages.lock.json in the root folder,
needed to cache packages in azure pipeline-->
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<!-- solves build error duplicate files -->
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
NOTE:
I also had to ad the azure step "nuget authentication" after the restore step (no config added); this might be due to packages from both official and organization sources.
//... YAML ...
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 6.0.300'
inputs:
version: 6.0.300
includePreviewVersions: true
- task: NuGetToolInstaller@1
displayName: 'Use NuGet '
- task: Cache@2
displayName: Cache
inputs:
key: 'nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**,!**/obj/**'
path: '$(NUGET_PACKAGES)'
cacheHitVar: 'CACHE_RESTORED'
restoreKeys: |
nuget | "$(Agent.OS)"
nuget
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: ProbablyTheBestSolution.Ever.sln
feedsToUse: config
nugetConfigPath: NuGet.Config
condition: ne(variables.CACHE_RESTORED, true)
- task: NuGetAuthenticate@1
displayName: 'NuGet Authenticate'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
//...