I have the following release pipeline for an asp.net 6 app which publishes the site to an IIS server
trigger:
- none
variables:
IISWebsiteName: 'MyAspNetApp'
resources:
pipelines:
- pipeline: 'buildPipeline'
project: 'My Asp Net App'
source: 'Build pipeline'
branch: 'main'
stages:
- stage: 'DeployeWebSite'
displayName: 'Deploy website'
pool:
vmImage: windows-latest
jobs:
- deployment: DeployWebsite
displayName: 'Deploy website'
environment: 'dev-web01.VMI835964'
strategy:
runOnce:
deploy:
steps:
- checkout: none
- download: 'buildPipeline'
name: 'DownloadBuildArtifacts'
displayName: 'Download build artifacts'
artifact: 'My Asp Net App'
- task: IISWebAppManagementOnMachineGroup@0
name: 'StopIIS'
displayName: 'Stop IIS website - ${{ variables.IISWebsiteName }}'
inputs:
IISDeploymentType: 'IISWebsite'
ActionIISWebsite: 'StopWebsite'
StartStopWebsiteName: '${{ variables.IISWebsiteName }}'
- script: echo '$(Pipeline.Workspace)\buildPipeline\My Asp Net App'
- task: IISWebAppDeploymentOnMachineGroup@0
name: 'DeployIIS'
displayName: 'Deploy IIS website - ${{ variables.IISWebsiteName }}'
inputs:
WebSiteName: '${{ variables.IISWebsiteName }}'
Package: '$(Pipeline.Workspace)\buildPipeline\My Asp Net App'
TakeAppOfflineFlag: true
- task: IISWebAppManagementOnMachineGroup@0
name: 'StartIIS'
displayName: 'Start IIS website - ${{ variables.IISWebsiteName }}'
inputs:
IISDeploymentType: 'IISWebsite'
ActionIISWebsite: 'StartWebsite'
StartStopWebsiteName: '${{ variables.IISWebsiteName }}'
Problem is that as soon as it the pipeline runs it does not clear the agent folder where temporarily uploads file (to replace IIS Website). Is there any way to force it to clean that folder?
Check this option: Clean the local repo on the agent
For release, check deployment section: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/jobs-deployment?view=azure-pipelines