使用 GITLAB CI/CD 将 ASP.NET Core 发布到 IIS

Azr*_*ria 7 gitlab-ci asp.net-core

我可以通过dotnet run.gitlab-ci.yml脚本上使用来运行 Web 应用程序。

stages:
    - build
build:
    stage: build
    before_script:
        - 'dotnet restore'
    script:
        - echo "Building the My Application"
        - "dotnet publish Eitms.Decoder.sln -c release"
        - "cd C:\\MyFolderContaints\\Eitms.Decoder.Backend"
        - "dotnet run"
    only:
        - release
Run Code Online (Sandbox Code Playgroud)

但是我怎样才能发布到 IIS 中呢?任何人都可以显示步骤?

谢谢

更新

HERE查看脚本后,仍然没有成功。我在这里做错了吗?

stages:
    - build    
    - deploy
build:
    stage: build
    before_script:
        - 'dotnet restore'
    script:
        - echo "Building the app"
        - "dotnet publish Eitms.Decoder.sln -c release"
    artifacts:
        untracked: true
    only:
        - release

deploy_staging:
    stage: deploy
    script:
        - echo "Deploy to IIS"
        - "dotnet publish Eitms.Decoder.Backend\\Eitms.Decoder.Backend.csproj -c release -o C:\\Secret Path\\PRODUCTION\\Secret Project"
    dependencies:
        - build
    only:
        - release
Run Code Online (Sandbox Code Playgroud)

Sim*_*mon 4

我不知道它是否仍然真实,而且我从未使用过 GitLab CI,但查看提供的脚本,我认为您只需在发布后将文件复制(使用 xcopy 等 CMD 命令)到 IIS 文件夹中,就像您想做同样的事情一样使用 CMD .bat 文件

脚步

  1. 发布项目
  2. 停止应用程序池
  3. 复制文件
  4. 启动应用程序池

例如(仅作为示例)

 dotnet publish "Eitms.Decoder.Backend\\Eitms.Decoder.Backend.csproj" -c release -o "C:\\Secret Path\\PRODUCTION\\Secret Project"
 appcmd stop apppool /apppool.name:"Secret Project APP POOL"
 xcopy "C:\\Secret Path\\PRODUCTION\\Secret Project" "C:\\inetpub\\wwwroot\\Secret Project" /s /e
 appcmd start apppool /apppool.name:"Secret Project APP POOL"
Run Code Online (Sandbox Code Playgroud)