Github Action DotNetCore sln 和项目在同一文件夹中

Saj*_*man 4 yaml .net-core github-actions

name: .NET Core
Run Code Online (Sandbox Code Playgroud)

on: push: 分支: [ master ] pull_request: 分支: [ master ]

工作:构建:

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
  run: dotnet build --configuration Release --no-restore
- name: Test
  run: dotnet test --no-restore --verbosity normal
Run Code Online (Sandbox Code Playgroud)

这是我的 yml 代码。它显示错误 MSBUILD:错误 MSB1003:指定项目或解决方案文件。当前工作目录不包含项目或解决方案文件。

[错误]进程已完成,退出代码为 1。

in dotnet restorestep 因为项目文件夹中的sln。如何解决这个问题呢

fab*_*oad 10

只需定义具有解决方案或项目文件的目录的路径。假设项目文件位置是src/MyProject/MyProject.csproj,那么Install dependencies步骤应该是:

- name: Install dependencies
  run: dotnet restore
  working-directory: src/MyProject
Run Code Online (Sandbox Code Playgroud)


小智 5

指定解决方案名称

- name: Build with dotnet
  run: dotnet build Document.Approval.sln --configuration Release

- name: dotnet publish
  run: dotnet publish Document.Approval.sln -c Release -o ${{env.DOTNET_ROOT}}/myapp
Run Code Online (Sandbox Code Playgroud)