Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Action DotNetCore sln and project in same folder

name: .NET Core

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
  run: dotnet build --configuration Release --no-restore
- name: Test
  run: dotnet test --no-restore --verbosity normal

this my yml code . it showing error MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

[error]Process completed with exit code 1.

in dotnet restore step because the sln in the project folder. how to solve this problem

like image 860
Sajidur Rahman Avatar asked Apr 13 '20 12:04

Sajidur Rahman


People also ask

Why is my SLN file not showing up in my project?

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. To fix this without moving .sln-file, follow the list below.

Can I create a GitHub action that runs a NET application?

Many .NET CLI commands are available, most of which could be used in the context of a GitHub Action. While there are plenty of GitHub Actions available in the Marketplace, you may want to author your own. You can create GitHub Actions that run .NET applications. For more information, see Tutorial: Create a GitHub Action with .NET

What is the DotNet/samples GitHub repository?

The dotnet/samples GitHub repository is home to many .NET sample source code projects, including the app in this tutorial. The generated CODE_METRICS.md file is navigable. This file represents the hierarchy of the projects it analyzed.

How does the DotNet SDK work with Docker?

ENTRYPOINT [ "dotnet", "/DotNet.GitHubAction.dll" ] The .NET app in this tutorial relies on the .NET SDK as part of its functionality. The Dockerfile creates a new set of Docker layers, independent from the previous ones. It starts from scratch with the SDK image, and adds the build output from the previous set of layers.


Video Answer


2 Answers

Just define path to the directory that has solution or project file. Assuming that project file location is src/MyProject/MyProject.csproj, then Install dependencies step should be:

- name: Install dependencies
  run: dotnet restore
  working-directory: src/MyProject
like image 69
fabasoad Avatar answered Jan 04 '23 20:01

fabasoad


Specify the solution name

- 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
like image 35
Cetin Yilmaz Avatar answered Jan 04 '23 21:01

Cetin Yilmaz