.net dotnet publish and deploy with ftp Github操作

enyaitl3  于 2023-10-21  发布在  .NET
关注(0)|答案(1)|浏览(139)

我正在尝试设置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/[email protected]
  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命令中指定的目录i
工作流没有失败,但没有传输正确的文件。我错过了什么?
提前感谢!

hsgswve4

hsgswve41#

  • 让它简单!!**

更改发布命令

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

然后只需从Release文件夹local-dir: ./Release/发送所有这些编译后的文件,而无需担心主文件夹。

- name: FTP Deploy
  uses: SamKirkland/FTP-Dep[email protected]
  with:
    ........
    local-dir: ./Release/

相关问题