使用发布配置文件通过 Azure DevOps 管道部署网站

问题描述 投票:0回答:1

我有一个使用 NET7/8 和 Blazor 构建的网站,我使用提供商提供的 Web 发布配置文件将其从 Visual Studio 部署到服务器提供商。

网络发布配置文件就是这样

<Project>
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://example.com</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <ProjectGuid>f723c835-b603-4dc7-9b00-c1845be8fa20</ProjectGuid>
    <MSDeployServiceURL>
        https://example.com:8172/msdeploy.axd?site=example.com
    </MSDeployServiceURL>
    <DeployIisAppPath>example.com</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>true</EnableMSDeployBackup>
    <EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
    <UserName>forumpur</UserName>
    <_SavePWD>true</_SavePWD>
    <TargetFramework>net7.0</TargetFramework>
    <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
  </PropertyGroup>
</Project>

我正在尝试在 Azure DevOps 中创建一个 YAML,以便从 Azure DevOps 自动部署网站的管道。

我在管道的创建中看到,有一个名为

MSDeploy Package Sync
的任务,但它没有我认为我需要的所有参数。

您对如何使用发布配置文件创建管道有什么建议吗?

azure-devops azure-pipelines publish-profiles
1个回答
0
投票

您可以尝试使用 DotNetCoreCLI@2 任务在管道中运行 '

dotnet publish
' 命令将网站部署到 IIS 服务器:

  1. 如果无法从 Internet(公共网络)访问 IIS 服务器,您需要在自己的本地计算机(或虚拟机)上设置一个可以访问 IIS 服务器的自托管代理

  2. 配置在自托管代理上运行的管道中的 DotNetCoreCLI@2 任务。

    jobs:
    - job: publish
      pool: 
        name: {name of the agent pool}
        demands: Agent.Name -equals {name of the agent}
      steps:
      - task: DotNetCoreCLI@2
        displayName: 'Publish webside'
        inputs:
          command: 'publish'
          publishWebProjects: true
          arguments: '-p:PublishProfile={name of Publish Profile}'
    

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.