I am working on a multi repo .NET workflow where the master solution has a dependence on 2 child projects.
My yml is able to to checkout all three repos without issue. When I run a dot net restore on the 2 child projects, everything works. However, when I restore the master solution, the dot net restore indicates it cannot find the 2 child projects.
Any idea what I am missing?
Here is an example of my yml
name: Pipeline for WebAPI Deployment
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Child1.NET Repository
uses: actions/checkout@v4
with:
repository: TheClient/Child1.NET
token: ${{ SuperSecretToken}}
path: Child1.NET
ref: 'main'
- name: Checkout Child2.NET Repository
uses: actions/checkout@v4
with:
repository: TheClient/Child2.NET
token: ${{ SuperSecretToken}}
path: Child2.NET
ref: 'main'
- name: Checkout Master.NET Repository
uses: actions/checkout@v4
with:
repository: TheClient/Master.NET
token: ${{ SuperSecretToken}}
path: Master.NET
ref: 'main'
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '7.0.x'
- name: Restore Dependencies for Child1.NET
run: dotnet restore Child1.NET/Child1.NET.sln
- name: Build Child1.NET
run: dotnet build Child1.NET/Child1.NET.sln --no-restore --configuration Release
- name: Restore Dependencies for Child2.NET
run: dotnet restore Child2.NET/Child2.NET.sln
- name: Build Child2.NET
run: dotnet build Child2.NET/Child2.NET.sln --no-restore --configuration Release
- name: Locate Child2.NET.csproj and Child1.NET.csproj Paths
run: |
$child2Path = Get-ChildItem -Path Child2.NET -Filter "Child2.NET.csproj" -Recurse -File | Select-Object -ExpandProperty FullName
echo "CHILD_2_PATH=$child2Path" | Out-File -Append -FilePath $env:GITHUB_ENV
$Child1NetPath = Get-ChildItem -Path Child1.NET -Filter "Child1.NET.csproj" -Recurse -File | Select-Object -ExpandProperty FullName
echo "CHILD1_NET_PATH=$Child1NetPath" | Out-File -Append -FilePath $env:GITHUB_ENV
shell: pwsh
- name: Locate Master.NET.sln File and Store Path
run: |
$slnPath = Get-ChildItem -Path Master.NET -Filter "Master.NET.sln" -Recurse -File | Select-Object -ExpandProperty FullName
echo "MASTER_SOLUTION_PATH=$slnPath" | Out-File -Append -FilePath $env:GITHUB_ENV
shell: pwsh
- name: Display MASTER_SOLUTION_PATH
run: echo "MASTER_SOLUTION_PATH is set to $env:MASTER_SOLUTION_PATH"
shell: bash
- name: Update Master.NET.sln File
run: |
$child2RelativePath = $env:CHILD_2_PATH -replace 'D:/a/Master.NET/Master.NET/', ''
$Child1RelativePath = $env:CHILD1_NET_PATH -replace 'D:/a/Master.NET/Master.NET/', ''
(Get-Content $env:MASTER_SOLUTION_PATH) `
-replace '..\\Child2.NET\\Child2.NET.csproj', $child2RelativePath.replace('\','/') `
-replace '..\\Child1.NET\\Child1.NET\\Child1.NET.csproj', $Child1RelativePath.replace('\','/') `
| Set-Content $env:MASTER_SOLUTION_PATH
shell: pwsh
- name: Display Updated Master.NET.sln File
run: cat $env:MASTER_SOLUTION_PATH
shell: bash
- name: Restore Dependencies for Master.NET
run: dotnet restore Master.NET/Master.NET.sln
- name: Build Master.NET
run: dotnet build Master.NET/Master.NET.sln --no-restore --configuration Release
I found the root cause of the issue. It turns out that GIT runners will change the case of your folder structure. You will need to display where the projects are located and then you will will need to change the project file of the main project to match the folder references. Utlimately, this is a small amount of work for an enormous gain.
Reach out if you need any help!!!