msbuild
msbuild copied to clipboard
[Feature Request]: Provide a way to remove specific properties from the implicit restore triggered by /restore
Summary
In https://github.com/dotnet/sdk/pull/38956 we had to jump through a bunch of hoops to navigate the situations where the SDK needs to trigger a 'separate restore' - meaning a Restore operation that doesn't include various properties that the user may want to be sent to the subsequent Build/Publish/etc invocation. The most common scenario here is TargetFramework.
Because TargetFramework negatively influences Restore, we remove it, perform a Restore, then perform the original call the user requested. This is both fragile, and it creates overhead in the build from running an entire separate MSBuild invocation.
There should be some mechanism to either use the existing -restoreProperty or a new flag to explicitly un-set properties for the Restore triggered by /restore, so that these call patterns could be accounted for by the engine itself, instead of callers having to patch it together.
Background and Motivation
This most clearly surfaces when people try to use the new -getProperty family of flags in conjunction with a build call that includes TFMs.
Proposed Feature
A new -rrp/-removeRestoreProperty flag that takes a list of properties to unset for a Restore call.
Alternative Designs
-rp could be extended to allow unset via -rp:Property=, though this would be ambiguous with an explicit set to an empty value.