【问题标题】:dotnet publish and deploy with ftp Github Actionsdotnet 使用 ftp Github Actions 发布和部署
【发布时间】:2020-07-25 23:42:15
【问题描述】:

我正在尝试将 Github Actions 设置为: -构建 .net 核心应用程序 - 测试应用程序(单元测试) - 发布(dotnet 发布) -部署到ftp服务器

我在最后一步遇到了一些问题。我正在使用此操作部署到 ftp:https://github.com/SamKirkland/FTP-Deploy-Action

它总是部署整个存储库,而不仅仅是发布文件。

我的工作流程:

name: BuildAndTest

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: 3.1.101
- name: Install dependencies
  run: dotnet restore
- name: Build with dotnet
  run: dotnet build --configuration Release --no-restore
- name: Test
  run: dotnet test --no-restore --verbosity normal
- name: Publish
  run: dotnet publish MyApp.sln --configuration Release --framework netcoreapp3.1 --output ./publish --runtime win-x86  --self-contained true -p:PublishTrimmed=true -p:PublishSingleFile=true
- name: FTP Deploy
  uses: SamKirkland/FTP-Deploy-Action@3.0.0
  with:
    # Deployment destination server & path. Formatted as protocol://domain.com:port/full/destination/path/
    ftp-server: ${{ secrets.FTP_SERVER }}
    # FTP account username
    ftp-username: ${{ secrets.FTP_USERNAME }}
    # FTP account password
    ftp-password: ${{ secrets.FTP_PASSWORD }}
    # The local folder to copy, defaults to root project folder
    local-dir: /home/runner/work/MyApp/MyApp/publish/

local-dir 指向我在 dotnet publish 命令中指定的目录

工作流程没有失败,但没有传输正确的文件。我错过了什么?

提前致谢!

【问题讨论】:

  • 你检查过FTP服务器日志吗?它对传输的文件有什么说明?
  • 我将 dotnet publish 命令更改为: dotnet publish --configuration Release --no-restore --output ./publish --self-contained true --runtime win-x86 -p:PublishTrimmed =true 帮助我将文件发布到正确的目录。接下来我使用了另一个更适合我需要的 ftp-action:github.com/marketplace/actions/ftp-action
  • @AndersTofte thx 我遇到了同样的问题,它已经解决了我的问题

标签: .net asp.net-core ftp github-actions dotnet-cli


【解决方案1】:

让它变得简单!!
更改发布命令

-name: Publish
    run: dotnet publish -c Release --output ./Release

然后只需从 Release 文件夹 local-dir: ./Release/ 发送文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-17
    • 1970-01-01
    相关资源
    最近更新 更多