I build a UWP app on Azure DevOps hosted build agent (Windows-2022, version 20220131.1).
Of course, I use Microsoft.NETCore.UniversalWindowsPlatform NuGet package.
As long as My app has F# code I have to hack a GateKeeper.xml and enable F# in it.
So I use PowerShell to do that
foreach ($file in gci -Recurse 'C:\Users\*\.nuget\packages\*.net.native.compiler\**\GatekeeperConfig.xml')
{
(gc $file.FullName) -replace '<FSharpRule on="true">','<FSharpRule on="false">' | sc $file.FullName
}
But for version 6.2.12 the content of Microsoft.NETCore.UniversalWindowsPlatform is present in C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.netcore.universalwindowsplatform\6.2.12\ where I have no admin rights to change anything on a build agent.
So I wonder if it is possible to force MSBuild to always use NuGet directly never using packages cached in Program Files?
If the agent and UWP adhere to 'normal' NuGet standards, you could try a nuget.config as follows:
Keep in mind though, that this might break caching facilities on agents.