Search code examples
.net-coreworkflowgithub-actions

Github action use repo name twice for .net git restore buld


Given this workflow and Code directory

Repo: RepoName

.github/workflow/workflow.file
.git
Src/Demo/Demo.csproj
Test
Demo.Sln

This workflow fails on the restore command with RepoName used twice when doing dotnet restore

name: Demo
env:
  DOTNET_CLI_TELEMETRY_OPTOUT: 1
on:
  push:
    paths:
      - 'Src/**'
      - 'Tests/**'
      - 'Demo.sln'      
      - '**/demo-workflow.yml'  
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v2   
      

      - name: Install .NET Core SDK
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '5.0.x'
    
      - name: Restore NuGet packages
        run: dotnet restore

Error received: /home/runner/.dotnet/sdk/5.0.406/NuGet.targets(290,5): error MSB3202: The project file "/home/runner/work/RepoName/RepoName/Src/WebApi/WebApi.csproj" was not found. [/home/runner/work/RepoName/RepoName/PaymentGateway.sln]

Tried variations of

  • dotnet restore 'Demo.sln'
  • dotnet restore '/Demo.sln'
  • dotnet restore '**/Demo.sln'

Solution

  • This is the correct behaviour.

    I did

    run: |
        ls ${{github.workspace}}
    

    and it revealed that some code were not in that branch