ci: fix NuGet cache path with NUGET_PACKAGES env var
- Add NUGET_PACKAGES env var at job level to pin package cache location - Change cache path from ~/.nuget/packages to runner.temp/.nuget/packages - Add id to cache steps and diagnostic 'Cache status' step to show hit/miss - Add DOTNET_NOLOGO and DOTNET_CLI_TELEMETRY_OPT_OUT for cleaner logs - Applied to build, test, and release jobs uniformly
This commit is contained in:
2 files changed
+37
-3
No files matched your search
+36
-3
@@ -14,6 +14,10 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPT_OUT: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -28,14 +32,21 @@ jobs:
|
||||
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
|
||||
|
||||
- name: Cache NuGet packages
|
||||
id: nuget-cache
|
||||
uses: actions/cache@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
path: ${{ runner.temp }}/.nuget/packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
|
||||
restore-keys: |
|
||||
nuget-${{ runner.os }}-
|
||||
|
||||
- name: Cache status
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "NuGet cache hit: ${{ steps.nuget-cache.outputs.cache-hit }}"
|
||||
|
||||
- name: Restore tools
|
||||
run: dotnet tool restore
|
||||
|
||||
@@ -47,6 +58,10 @@ jobs:
|
||||
|
||||
test:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPT_OUT: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -61,14 +76,21 @@ jobs:
|
||||
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
|
||||
|
||||
- name: Cache NuGet packages
|
||||
id: nuget-cache
|
||||
uses: actions/cache@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
path: ${{ runner.temp }}/.nuget/packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
|
||||
restore-keys: |
|
||||
nuget-${{ runner.os }}-
|
||||
|
||||
- name: Cache status
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "NuGet cache hit: ${{ steps.nuget-cache.outputs.cache-hit }}"
|
||||
|
||||
- name: Run tests (if any test projects exist)
|
||||
shell: pwsh
|
||||
run: |
|
||||
@@ -89,6 +111,10 @@ jobs:
|
||||
- test
|
||||
if: startsWith(gitea.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
NUGET_PACKAGES: ${{ runner.temp }}/.nuget/packages
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPT_OUT: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -103,14 +129,21 @@ jobs:
|
||||
DOTNET_INSTALL_DIR: ${{ runner.temp }}\dotnet
|
||||
|
||||
- name: Cache NuGet packages
|
||||
id: nuget-cache
|
||||
uses: actions/cache@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
path: ${{ runner.temp }}/.nuget/packages
|
||||
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '.config/dotnet-tools.json') }}
|
||||
restore-keys: |
|
||||
nuget-${{ runner.os }}-
|
||||
|
||||
- name: Cache status
|
||||
if: always()
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host "NuGet cache hit: ${{ steps.nuget-cache.outputs.cache-hit }}"
|
||||
|
||||
- name: Restore tools
|
||||
run: dotnet tool restore
|
||||
|
||||
|
||||
@@ -45,3 +45,4 @@ Desktop.ini
|
||||
|
||||
# Internal dev memory (stays local, not published)
|
||||
memory-bank/
|
||||
memorybank.md
|
||||
Reference in new issue
Block a user