I'm trying to pack several packages, however the --no-build argument or option is being ignored and several projects including test projects are being built.
I have tried different combinations on using "NoBuild" but for some reason extra projects are always referenced, how can i pack without build or using additional projects in pack?
Main YAML:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- develop
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
storeBuildNumber: $(Build.BuildNumber)
NugetVersion: '1.1.0-unstable'
steps:
- template: AzureDevOps/Templates/provision-template.yml
parameters:
projects: |
**/ProjectA.csproj
**/ProjectB.csproj
Template YAML:
parameters:
projects: ''
steps:
- task: DotNetCoreCLI@2
displayName: "ProvisionRestoreProjects"
inputs:
command: 'restore'
projects: ${{ parameters.projects }}
arguments: >
-s "http://MyFeed/nuget/Feed-feature-yaml/"
-k "ASDF3234234SDSD"
- task: DotNetCoreCLI@2
displayName: "ProvisionBuildProjects"
inputs:
command: 'build'
projects: ${{ parameters.projects }}
arguments: '--configuration release --no-cache'
- task: DotNetCoreCLI@2
displayName: "ProvisionPackProjects"
inputs:
command: 'pack'
nobuild: true
projects: ${{ parameters.projects }}
versioningScheme: 'byEnvVar'
versionEnvVar: 'NugetVersion'
arguments: '--no-build'
- task: DotNetCoreCLI@2
displayName: "ProvisionPushProjects"
inputs:
command: custom
custom: nuget
arguments: >
push "$(Build.ArtifactStagingDirectory)\*.nupkg"
-s "http://MyFeed/nuget/Feed-feature-yaml/"
-k "ASDF3234234SDSD"
Well i started with Cinderella and ended up with Frankenstein, here are my findings and the solution that worked for me.
Findings
Solution
Main YAML:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- develop
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
storeBuildNumber: $(Build.BuildNumber)
NugetVersion: '1.1.0-unstable'
steps:
- task: PowerShell@2
displayName: "Get Nuget Feed from config"
inputs:
targetType: 'inline'
script: >
$currentLocation = "$(get-location)"
cd $(Build.SourcesDirectory)
#Get file
$file = ".\NuGet.Config"
$content = (Get-Content $file)
Write-Output ("file content: $content")
$regex = '(?<=<add key="CurrentBranchFeed" value=")[^"]*'
Write-Output ("regex: $regex")
$nugetFeed = [regex]::match($content,$regex).Groups[0].Value
Write-Output ("Result: $nugetFeed")
Write-Output ("##vso[task.setvariable variable=NugetFeed;]$nugetFeed")
cd $currentLocation
- template: AzureDevOps/Templates/provision-template.yml
parameters:
projects: |-
**/ProjectA.csproj
**/ProjectB.csproj
Template YAML:
parameters:
projects: ''
steps:
- task: PowerShell@2
displayName: "UpdateProjectsToPack"
inputs:
targetType: 'inline'
script: '
$currentProjects = "${{ parameters.projects }}"
$currentProjects = $currentProjects.replace("`r","")
$ProjectsToPack = $currentProjects.replace("`n",";")
Write-Output ("##vso[task.setvariable variable=ProjectsToPack;]$ProjectsToPack")
'
- task: DotNetCoreCLI@2
displayName: "ProvisionRestoreProjects"
inputs:
command: 'restore'
projects: '${{ parameters.projects }}'
feedsToUse: 'config'
nugetConfigPath: '$(Build.SourcesDirectory)/NuGet.Config'
- task: DotNetCoreCLI@2
displayName: "ProvisionBuildProjects"
inputs:
command: 'build'
projects: '${{ parameters.projects }}'
arguments: '--configuration release --no-cache'
- task: DotNetCoreCLI@2
displayName: "ProvisionPackProjects"
inputs:
command: 'pack'
nobuild: true
packagesToPack: $(ProjectsToPack)
versioningScheme: 'byEnvVar'
versionEnvVar: 'NugetVersion'
arguments: '--no-dependencies --force --no-cache'
- task: DotNetCoreCLI@2
displayName: "ProvisionPushProjects"
inputs:
command: custom
custom: nuget
arguments: >
push "$(Build.ArtifactStagingDirectory)\*.nupkg"
-s "$(NugetFeed)"
-k "ASDF3234234SDSD"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With