A solution that is built via Azure DevOps pipeline has some projects that use conditional package references such as:
<Choose>
<When Condition="'$(Configuration)'=='Debug'">
<ItemGroup>
<PackageReference Include="Mock.MyPackage" Version="1.0.0" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="MyPackage" Version="1.2.0" />
</ItemGroup>
</Otherwise>
</Choose>
The package source is a private NuGet feed.
The dotnet restore task does not respect the conditional package selection. (it restores Mock.MyPackage)
Question:
how can I conditionally restore packages (based on a $Configuration) ?
Remarks:
I have also tried restoring during Visual Studio Build task by specifying an MsBuild argument: /t:restore.
In that case it fails with a message: Failed to retrieve information about XX from remote source. If this command can restore packages how can I specify authorization args for the private feed ?
There is an issue on Github: https://github.com/NuGet/Home/issues/5895 where such issue is mentioned at the end.