dotnet / dotnet/msbuild

[Feature Request]: Provide a way to remove specific properties from the implicit restore triggered by /restore

Open
#9,778 6 comments 1 reaction 0 assignees View on GitHub
backlog Feature Request Functionality:Restore needs-design Priority:2 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.