Steps to reproduce
-
Create a local temporary build of some packages for testing
-
Add the packages from (1) to <packageSources>
-
Set globalPackagesFolder in NuGet.config to avoid having the packages from (1) corrupt the shared cache
<config>
<add key="globalPackagesFolder" value="./artifacts/package-cache" />
</config>
-
Restore the solution
Expected results
Arcade/NuGet restores packages to the ./artifacts/package-cache folder to avoid corrupting per-user cache with temporary artifacts.
Actual results
The restore process ignores this standard configuration property and corrupts the cache anyway.
It appears one of the following lines are responsible for this unexpected behavior:
|
<!-- Respect environment variable for the NuGet Packages Root if set; otherwise, use the current default location --> |
|
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' != ''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)'))</NuGetPackageRoot> |
|
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' and '$(NUGET_PACKAGES)' != ''">$([MSBuild]::NormalizeDirectory('$(NUGET_PACKAGES)'))</NuGetPackageRoot> |
|
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' and '$(OS)' == 'Windows_NT'">$([MSBuild]::NormalizeDirectory('$(UserProfile)', '.nuget', 'packages'))</NuGetPackageRoot> |
|
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' and '$(OS)' != 'Windows_NT'">$([MSBuild]::NormalizeDirectory('$(HOME)', '.nuget', 'packages'))</NuGetPackageRoot> |
|
function GetNuGetPackageCachePath() { |
|
if ($env:NUGET_PACKAGES -eq $null) { |
|
# Use local cache on CI to ensure deterministic build. |
|
# Avoid using the http cache as workaround for https://github.com/NuGet/Home/issues/3116 |
|
# use global cache in dev builds to avoid cost of downloading packages. |
|
# For directory normalization, see also: https://github.com/NuGet/Home/issues/7968 |
|
if ($useGlobalNuGetCache) { |
|
$env:NUGET_PACKAGES = Join-Path $env:UserProfile '.nuget\packages\' |
|
} else { |
|
$env:NUGET_PACKAGES = Join-Path $RepoRoot '.packages\' |
|
$env:RESTORENOCACHE = $true |
|
} |
|
} |
|
|
|
return $env:NUGET_PACKAGES |
|
} |
Steps to reproduce
Create a local temporary build of some packages for testing
Add the packages from (1) to
<packageSources>Set
globalPackagesFolderin NuGet.config to avoid having the packages from (1) corrupt the shared cacheRestore the solution
Expected results
Arcade/NuGet restores packages to the ./artifacts/package-cache folder to avoid corrupting per-user cache with temporary artifacts.
Actual results
The restore process ignores this standard configuration property and corrupts the cache anyway.
It appears one of the following lines are responsible for this unexpected behavior:
arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/RepoLayout.props
Lines 15 to 19 in 2dcda00
arcade/eng/common/tools.ps1
Lines 543 to 558 in 2dcda00