Azure DevOps 发布.Net项目到Windows IIS站点之通过公网IP(账号、密码)

在Azure DevOps中 通过指定公网IP发布代码到指定目录

# ASP.NET Core (.NET Core 7.0)
# Build and test ASP.NET Core projects targeting .NET Core 7.0.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-2022'

variables:
- group: GeexPublish
- name: my-user-variable
  value: $[variables.UserName] # uses runtime expression
- name: my-passed-variable
  value: $[variables.PassWord] # uses runtime expression
- name: buildConfiguration
  value: 'Release'
- name: publishFolder
  value: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId)'
- name: solution
  value: '**/Platform.Client.csproj'

stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: Build
    displayName: 'Build job'
    steps:
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'Build solution'

    - script: dotnet publish --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)
      displayName: 'Publish solution'

    - task: PublishBuildArtifacts@1
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)'
        artifactName: 'drop'
        publishLocation: 'Container'


- stage: Deploy
  displayName: Deploy stage
  jobs:
  - job: DeployToIIS
    displayName: Deploy to IIS
    pool:
      vmImage: 'windows-2022'
    steps:
    - task: DownloadBuildArtifacts@0
      inputs:
        buildType: 'current'
        downloadType: 'single'
        artifactName: 'drop'
        downloadPath: '$(System.ArtifactsDirectory)'

    - script: choco install webdeploy -y
      displayName: 'Install Web Deploy'

    - script: |
        msdeploy -verb:sync ^
        -source:contentPath="$(System.ArtifactsDirectory)/drop" ^
        -dest:contentPath="D:xxxx\xxx",computerName="https://xxx.xxxx.xxx.xx:8172/msdeploy.axd",userName=$(my-user-variable),password=$(my-passed-variable),authType="Basic" ^
        -allowUntrusted
      displayName: 'Deploy to IIS'




posted @ 2023-11-13 21:57  初久的私房菜  阅读(8059)  评论(0编辑  收藏  举报
作者:初久的私房菜
好好学习,天天向上
返回顶部小火箭
好友榜:
如果愿意,把你的博客地址放这里
张弛:https://blog.zhangchi.fun/