Azure DevOps Pipeline基于IIS Web Deploy自动部署
分类: Azure指南 ◆ 标签: #Azure #DevOps ◆ 发布于: 2023-06-19 12:08:29

如下是网站AzureDeveloper.CN
的实际部署pipeline
脚本:
# ASP.NET Core # Build and test ASP.NET Core projects targeting .NET Core. # Add steps that run tests, create a NuGet package, deploy, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core trigger: branches: include: - release paths: include: - AzureDeveloper.OrchardCore.Web variables: - group: webdeploy_variables - name: buildConfiguration value: 'Release' stages: - stage: restore_whole_solution displayName: Restore whole solution pool: vmImage: windows-latest jobs: - job: restore_azuredeveloper_orchardcore_themes displayName: Restore Project AzureDeveloper Themes FirstBegin workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: restore projects: 'AzureDeveloper.OrchardCore.Themes.FirstBegin/AzureDeveloper.OrchardCore.Themes.FirstBegin.csproj' - job: restore_azuredeveloper_orchardcore_article displayName: Restore Project AzureDeveloper OrchardCore Article dependsOn: restore_azuredeveloper_orchardcore_themes workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: restore projects: 'AzureDeveloper.OrchardCore.Modules.AzureArticle/AzureDeveloper.OrchardCore.Modules.Articles.csproj' - job: restore_azuredeveloper_orchardcore_Search_ChineseAnalyzer displayName: Restore Project AzureDeveloper OrchardCore Search ChineseAnalyzer dependsOn: restore_azuredeveloper_orchardcore_article workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: restore projects: 'AzureDeveloper.OrchardCore.Search.ChineseAnalyzer/AzureDeveloper.OrchardCore.Search.ChineseAnalyzer.csproj' - job: restore_azuredeveloper_orchardcore_web dependsOn: restore_azuredeveloper_orchardcore_Search_ChineseAnalyzer displayName: Restore Project AzureDeveloper OrchardCore Web workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: restore projects: 'AzureDeveloper.OrchardCore.Web/AzureDeveloper.OrchardCore.Web.csproj' - stage: build_whole_solution displayName: Build Whole Solution pool: vmImage: windows-latest jobs: - job: build_AzureDeveloper_OrchardCore_Themes displayName: Build Project Azure Developer OrchardCore Themes workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: build projects: 'AzureDeveloper.OrchardCore.Themes.FirstBegin/AzureDeveloper.OrchardCore.Themes.FirstBegin.csproj' arguments: --configuration $(buildConfiguration) displayName: Common> dotnet build $(buildConfiguration) - job: build_AzureDeveloper_OrchardCore_Module_Article displayName: Build Project Azure Developer OrchardCore Module Article dependsOn: build_AzureDeveloper_OrchardCore_Themes workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: build projects: 'AzureDeveloper.OrchardCore.Modules.AzureArticle/AzureDeveloper.OrchardCore.Modules.Articles.csproj' arguments: --configuration $(buildConfiguration) displayName: Common> dotnet build $(buildConfiguration) - job: build_AzureDeveloper_OrchardCore_Module_Search displayName: Build Project Azure Developer OrchardCore Module Search dependsOn: build_AzureDeveloper_OrchardCore_Module_Article workspace: clean: true steps: - task: DotNetCoreCLI@2 inputs: command: build projects: 'AzureDeveloper.OrchardCore.Search.ChineseAnalyzer/AzureDeveloper.OrchardCore.Search.ChineseAnalyzer.csproj' arguments: --configuration $(buildConfiguration) displayName: Common> dotnet build $(buildConfiguration) - job: build_AzureDeveloper_OrchardCore_Web displayName: Build Project AzureDeveloper OrchardCore Web dependsOn: build_AzureDeveloper_OrchardCore_Module_Search steps: - task: DotNetCoreCLI@2 inputs: command: build projects: 'AzureDeveloper.OrchardCore.Web/AzureDeveloper.OrchardCore.Web.csproj' arguments: --configuration $(buildConfiguration) displayName: Web> dotnet build $(buildConfiguration) - job: public_web_project_to_zip displayName: Publish Web Project To a Zip File dependsOn: build_AzureDeveloper_OrchardCore_Web steps: - task: DotNetCoreCLI@2 inputs: command: publish projects: 'AzureDeveloper.OrchardCore.Web/AzureDeveloper.OrchardCore.Web.csproj' arguments: --configuration $(buildConfiguration) publishWebProjects: true displayName: dotnet public --configuration $(buildConfiguration) - task: PublishPipelineArtifact@1 inputs: targetPath: '$(System.DefaultWorkingDirectory)/AzureDeveloper.OrchardCore.Web/bin/Release/net7.0/' artifactType: 'pipeline' artifactName: 'AzureDeveloper.OrchardCore.Web' - stage: deploy_web_project_to_production displayName: Deploy Web Project to Production pool: vmImage: windows-latest jobs: - deployment: deploy_web_project workspace: clean: true environment: name: SouthEastVM resourceType: VirtualMachine strategy: rolling: deploy: steps: - script: echo $(System.DefaultWorkingDirectory) - task: IISWebAppDeploymentOnMachineGroup@0 inputs: WebSiteName: 'www.azuredeveloper.cn' Package: '$(System.DefaultWorkingDirectory)\..\AzureDeveloper.OrchardCore.Web\*.zip' TakeAppOfflineFlag: true