I added a GitHub action to my repository to test my branch and then merged it to the master, but it gave me this error:
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
There are four projects in the solution.
How can I solve this problem?
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-restore
This usually happens when you are starting with a single project, and your .sln-file ends up inside a project folder. Easiest way out of this, is to move .sln-file one folder level up.
Additional resource for moving the .sln-file (credit to @Charles): https://stackoverflow.com/a/626646/14072498
Just click on the solution in the Solution Explorer and then click on "Save myProject.sln as..." in the File Menu. This will save your .sln in the folder that you choose without breaking the references.
To fix this without moving .sln-file, follow the list below.
Replace WebApplication.sln
and WebApplication/WebApplication.csproj
with corresponding names from your app below.
run: dotnet restore ./WebApplication.sln
run: dotnet build WebApplication/WebApplication.csproj --configuration Release --no-restore
For the tests, point to .sln-file
run: dotnet test ./WebApplication.sln --configuration Release --no-restore