diff --git a/.azure/pipelines/azure-pipelines-build.yml b/.azure/pipelines/azure-pipelines-build.yml index 9b9d1fdc..d181df11 100644 --- a/.azure/pipelines/azure-pipelines-build.yml +++ b/.azure/pipelines/azure-pipelines-build.yml @@ -16,7 +16,7 @@ parameters: stages: - stage: build - displayName: Build and Publish + displayName: Build and Publish jobs: - job: build @@ -24,8 +24,7 @@ stages: steps: - task: PowerShell@2 - displayName: Clean Agent Folders - enabled: true + displayName: Clean-up Agent Folders env: BUILD_ARTIFACTSTAGINGDIRECTORY: $(Build.ArtifactStagingDirectory) BUILD_BINARIESDIRECTORY: $(Build.BinariesDirectory) @@ -35,17 +34,13 @@ stages: targetType: inline script: | if (Test-Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY) { - Remove-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue } if (Test-Path $env:BUILD_BINARIESDIRECTORY) { - Remove-Item -Path "$env:BUILD_BINARIESDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item -Path "$env:BUILD_BINARIESDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue } - #if (Test-Path $env:BUILD_SOURCESDIRECTORY) { - # Remove-Item -Path "$env:BUILD_SOURCESDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue - #} - if (Test-Path $env:BUILD_PUBLISHDIRECTORY) { Remove-Item -Path "$env:BUILD_PUBLISHDIRECTORY" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue } @@ -53,7 +48,6 @@ stages: - task: PowerShell@2 displayName: Create AgentCapabilities Environment Variables - enabled: true env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) inputs: @@ -112,7 +106,7 @@ stages: clean: true - task: PowerShell@2 - displayName: Cleanup Published Files + displayName: Clean-up Published Files env: BUILD_BUILDNUMBER: $(Build.BuildNumber) BUILD_ARTIFACTSTAGINGDIRECTORY: $(Build.ArtifactStagingDirectory) @@ -258,3 +252,31 @@ stages: inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)' ArtifactName: '${{parameters.PublishFolder}}' + + - task: PowerShell@2 + displayName: Clean-up Agent Folders + condition: always() + env: + BUILD_ARTIFACTSTAGINGDIRECTORY: $(Build.ArtifactStagingDirectory) + BUILD_BINARIESDIRECTORY: $(Build.BinariesDirectory) + BUILD_SOURCESDIRECTORY: $(Build.SourcesDirectory) + BUILD_PUBLISHDIRECTORY: "$(Build.BuildDirectory)/${{parameters.PublishFolder}}" + inputs: + targetType: inline + script: | + if (Test-Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY) { + Remove-Item -Path "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue + } + + if (Test-Path $env:BUILD_BINARIESDIRECTORY) { + Remove-Item -Path "$env:BUILD_BINARIESDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue + } + + if (Test-Path $env:BUILD_SOURCESDIRECTORY) { + Remove-Item -Path "$env:BUILD_SOURCESDIRECTORY\*" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue + } + + if (Test-Path $env:BUILD_PUBLISHDIRECTORY) { + Remove-Item -Path "$env:BUILD_PUBLISHDIRECTORY" -Filter '*.*' -Recurse -Force -ErrorAction SilentlyContinue + } + pwsh: true diff --git a/.azure/pipelines/azure-pipelines.yml b/.azure/pipelines/azure-pipelines.yml index 0cd0000b..a53f4b56 100644 --- a/.azure/pipelines/azure-pipelines.yml +++ b/.azure/pipelines/azure-pipelines.yml @@ -20,7 +20,7 @@ variables: - name: ProjectFile value: 'src/$(ApplicationName)/$(ApplicationName).csproj' - name: PublishFolder - value: Publish123 + value: p stages: - template: azure-pipelines-build.yml@self