Skip to content

Commit

Permalink
Improve diagnostic output + refactor handling of packages-to-be-publi…
Browse files Browse the repository at this point in the history
…shed directory in `archetype-sdk-tool-dotnet.yml` (#5007)

#5007
  • Loading branch information
Konrad Jamrozik authored Jan 4, 2023
1 parent a9c4820 commit 9ef966d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
22 changes: 14 additions & 8 deletions eng/pipelines/templates/stages/archetype-sdk-tool-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ variables:
value: ''
${{ if not(parameters.NoWarn) }}:
value: -warnaserror
# A path to directory to contain the output of "dotnet pack" call,
# to be consumed as input by "publish" task.
- name: packagesToPublishDir
value: $(Build.ArtifactStagingDirectory)/packages

stages:
- stage: BuildTestAndPackage
Expand All @@ -69,7 +73,7 @@ stages:
inputs:
version: '${{ coalesce( parameters.DotNetCoreVersion, variables.DotNetCoreVersion) }}'

- script: 'dotnet pack /p:ArtifactsPackagesDir=$(Build.ArtifactStagingDirectory)/packages $(Warn) -c Release'
- script: 'dotnet pack /p:ArtifactsPackagesDir=$(packagesToPublishDir) $(Warn) -c Release'
displayName: 'Build and Package'
workingDirectory: '${{ coalesce(parameters.PackageDirectory, parameters.ToolDirectory) }}'
env:
Expand All @@ -83,20 +87,22 @@ stages:
BuildMatrix: ${{ parameters.StandaloneExeMatrix }}
TargetDirectory: '${{ coalesce(parameters.PackageDirectory, parameters.ToolDirectory) }}'

# This step creates "$(Build.ArtifactStagingDirectory)/packages" directory if it doesn't exist.
# This step creates "$(packagesToPublishDir)" directory if it doesn't exist.
# This step is necessary since migration to net6.0. This is because since net6.0,
# in case the "Build and Package" above would not output any packages to this directory,
# the "Publish to packages artifact" step below would fail on missing directory.
- pwsh: |
if (!(Test-Path -PathType container "$(Build.ArtifactStagingDirectory)/packages")) {
New-Item -ItemType Directory -Path "$(Build.ArtifactStagingDirectory)/packages"
Write-Host "Created directory $(Build.ArtifactStagingDirectory)/packages"
if (!(Test-Path -PathType container "$(packagesToPublishDir)")) {
New-Item -ItemType Directory -Path "$(packagesToPublishDir)"
Write-Host "Created directory ""$(packagesToPublishDir)"""
} else {
Write-Host "Directory $(Build.ArtifactStagingDirectory)/packages already exists. Nothing to do."
Write-Host "Directory ""$(packagesToPublishDir)"" already exists. Nothing to do."
Write-Host "Directory ""$(packagesToPublishDir)"" contents:"
Get-ChildItem $(packagesToPublishDir) | ForEach-Object { Write-Host $_ }
}
displayName: Create directory for packages to publish if absent
displayName: Create XOR list contents of directory of packages to publish
- publish: $(Build.ArtifactStagingDirectory)/packages
- publish: $(packagesToPublishDir)
displayName: Publish to packages artifact
artifact: packages
condition: succeededOrFailed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ parameters:

steps:
- pwsh: |
mkdir -p "$(Build.ArtifactStagingDirectory)/binaries"
displayName: Create destination directory
New-Item -ItemType Directory -Path "$(Build.ArtifactStagingDirectory)/binaries" -Force
Write-Host "Created directory ""$(Build.ArtifactStagingDirectory)/binaries"""
displayName: Create .NET standalone packs destination directory
- ${{ each target in parameters.BuildMatrix }}:
- pwsh: |
Expand Down

0 comments on commit 9ef966d

Please sign in to comment.