Skip to content

Commit dddd1d4

Browse files
authored
Spec: NuGet onboarding to Unified Settings in Visual Studio
2 parents e4593c2 + 1827b6e commit dddd1d4

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# NuGet onboarding to Unified Settings in Visual Studio
2+
<!-- Replace `Title` with an appropriate title for your design -->
3+
4+
- Donnie Goodson ([donnie-msft](https://github.com/donnie-msft))
5+
- GitHub Issue <https://github.com/NuGet/Client.Engineering/issues/2712>
6+
7+
## Summary
8+
9+
<!-- One-paragraph description of the proposal. -->
10+
11+
Visual Studio Options are moving to a new user interface called "Unified Settings" (abbr. USX).
12+
The Visual Studio (VS) IDE team is responsible for the UI controls, and individual product teams will maintain a JSON file declaring the structure and data types for settings in the IDE in addition to any custom commands.
13+
14+
## Motivation
15+
16+
<!-- Why are we doing this? What pain points does this solve? What is the expected outcome? -->
17+
18+
The Visual Studio IDE team created Unified Settings to make the configuration experience have a Consistent UI, scoping capabilities, and the ability to share and sync settings across devices.
19+
A blog was published to expand on this motivation and collect feedback from the community, [Unified Settings: Share Your Feedback](https://devblogs.microsoft.com/visualstudio/unifiedsettings/).
20+
This is currently a VS Preview-only feature.
21+
22+
For NuGet, the improved maintainability will reduce ad-hoc UI code and allow the team to focus on the effect of the settings, and not the UI around the settings.
23+
The expectation is significantly less usability and accessibility issues around NuGet's VS Options because of this standardized UI.
24+
25+
## Explanation
26+
27+
### Functional explanation
28+
29+
<!-- Explain the proposal as if it were already implemented and you're teaching it to another person. -->
30+
<!-- Introduce new concepts, functional designs with real life examples, and low-fidelity mockups or pseudocode to show how this proposal would look. -->
31+
32+
All of NuGet's legacy VS Options pages will be migrated to USX.
33+
The General page will be tackled first, and is the main scope for this spec.
34+
35+
Normally, USX manages user settings in a custom JSON settings file; however, NuGet will instead continue to use our custom `NuGet.Config` to store settings values.
36+
We will maintain interoperability with our backing store by implementing an External Settings API provided by the VS IDE team.
37+
38+
A mockup of the NuGet General Options page in Unified Settings is shown below.
39+
40+
![Mockup showing a prototype of the NuGet General Options page in Unified Settings](../../meta/resources/UnifiedSettings/general-prototype.png)
41+
42+
### Settings are stored in NuGet.Config
43+
44+
Since the `NuGet.Config` is an external backing store, NuGet.Client can specify explanatory text and a hyperlink button that points to its location.
45+
The text shown in the mockup is "These settings are stored in NuGet.config".
46+
Pressing the hyperlink button on `NuGet.Config` will open the file in the VS editor.
47+
48+
Given that there can be multiple `NuGet.Config` files, the plan for now is to have it open the first `NuGet.Config` which is closest to the solution, which would be the first file listed in the "Configuration Files" page of NuGet's legacy settings, today.
49+
50+
#### Clear Local NuGet Resources
51+
52+
The `Clear local NuGet resources` button from legacy options will be shown as a hyperlink button in USX under the root section's title ("General").
53+
54+
Pressing the hyperlink button will open a modal dialog window indicating the status of the operation of clearing the resources from disk.
55+
The mockup below shows the button and the effect of pressing it:
56+
57+
![Mockup showing the Clear local NuGet resources hyperlink button and the modal dialog which opens once pressed](../../meta/resources/UnifiedSettings/clear-command-dialog.png)
58+
59+
#### Error messages
60+
61+
When the `NuGet.Config` has an invalid value, the UI will show a blank selection, or an indeterminate state checkbox, and will be accompanied by a simple error message indicating that the value in the backing store was somehow invalid.
62+
63+
Any action taken inside the USX page will overwrite that invalid value in the backing store (`NuGet.Config`) according to `NuGet.Configuration`.
64+
65+
For any fatal errors, such as unable to load the `NuGet.Config` at all due to parsing errors, or similar, the following will occur:
66+
67+
- An error message will be shown under the "General" section label.
68+
> "We're unable to read one or more `NuGet.Config` configuration files in this solution. See `(docs link)` for more information."
69+
- The `NuGet.Config` will be a hyperlink button which opens the Configuration Files page of NuGet Settings as it is done with the hyperlink, [Settings are stored in NuGet.Config](#settings-are-stored-in-nugetconfig).
70+
The shortcut allows the customer to view all paths to configured nuget.config files and open them in the VS editor easily and correct the issue.
71+
- A retry button is provided by USX.
72+
- All the edit controls in the section become disabled; the user cannot interact with them while in an error state.
73+
- The error state can be cleared by if the `NuGet.Config` is modified externally to VS.
74+
75+
#### Help icons
76+
77+
Each UI element in USX can have a help link attached.
78+
In the mockup, these are shown as a circled `?` icon.
79+
Pressing one of these opens the relevant Documentation page, and is anchored to the corresponding section in the document.
80+
81+
### Technical explanation
82+
83+
<!-- Explain the proposal in sufficient detail with implementation details, interaction models, and clarification of corner cases. -->
84+
85+
### Registration
86+
87+
The NuGet.Client repository will maintain a `registration.json` file to declare all VS Settings, including localizible names, data types, default values, command implementations, and any dependencies among the values of other settings.
88+
89+
The `registration.json` will use the `"type": "external"` mode because our product stores configuration in a custom backing store: One or more `NuGet.Config` files.
90+
91+
### Command: Clear Local Resources
92+
93+
NuGet.Client will create a new modal dialog to indicate that the Clear Local Resources command is in-progress and has completed.
94+
The modal dialog will replace our WinForms controls that indicate the same information.
95+
96+
Since USX doesn't support dynamically changing text blocks, the modal is the simplest and most effective form of UI we can adopt, while also allowing us to expand the capabilities of this command in VS in the future.
97+
98+
The invocation of the `LocalsCommandRunner` which is supported by legacy VS settings will be adapted to a USX Command.
99+
A USX Command invokes a command in VS using the VS SDK and the extensible menu command system.
100+
Therefore, our Visual Studio Command Table (VSCT) file will be updated with a new command, which executes `LocalsCommandRunner` in the following way:
101+
102+
1. Open a modal dialog window.
103+
- State that NuGet resources are being cleared.
104+
- Prevent the user from accessing VS components like the Restore or the NuGet Package Manager since this could cause conflicts with the operation of clearing local resources.
105+
- Show an indeterminate progress indicator.
106+
- A Cancel button cannot be supported at this time.
107+
(See Future Possibilities)
108+
1. Execute `LocalsCommandRunner` in the same manner as legacy VS Settings.
109+
1. Display text indicating the completion of the command (or any error messages) and a close button on the modal dialog.
110+
111+
### External Settings API
112+
113+
To map each of our registered UI elements in Unified Settings to the `NuGet.Configuration` APIs, we must implement an `IExternalSettingsProvider`.
114+
USX will invoke the following on our provider:
115+
- `GetValueAsync` is called by USX when obtaining values from the `NuGet.Configuration`.
116+
117+
- `SetValueAsync` is called by USX when the user has made a change to the setting and it needs to be persisted in the backing store.
118+
119+
The provider will respond to those API calls using the following `NuGet.Configuration` types for retrieving and persisting NuGet Configuration data:
120+
121+
- BindingRedirectBehavior
122+
- PackageRestoreConsent
123+
- PackageManagementFormat
124+
125+
Other notes:
126+
- The provider is exported by providing GUID in the `registration.json`.
127+
128+
- The `ISettings` service will be obtained by the provider using ServiceLocator.
129+
130+
- Any `SettingsChanged` events will invalidate the provider's state and cause USX to repopulate the page's data.
131+
132+
133+
## Drawbacks
134+
135+
<!-- Why should we not do this? -->
136+
No drawbacks have been identified.
137+
138+
## Rationale and alternatives
139+
140+
<!-- Why is this the best design compared to other designs? -->
141+
<!-- What other designs have been considered and why weren't they chosen? -->
142+
<!-- What is the impact of not doing this? -->
143+
- The Clear Local Resources command could first open the modal dialog and provide a "start" button to allow the customer to begin the process of clearing the resources.
144+
This would be a change from the legacy behavior, but customers may be curious about the new USX experience, and initiate the command by mistake.
145+
146+
## Prior Art
147+
148+
<!-- What prior art, both good and bad are related to this proposal? -->
149+
<!-- Do other features exist in other ecosystems and what experience have their community had? -->
150+
<!-- What lessons from other communities can we learn from? -->
151+
<!-- Are there any resources that are relevant to this proposal? -->
152+
153+
To achieve parity with the legacy Visual Studio Options for NuGet, those UI elements and implementation will serve as a starting point for the migration to Unified Settings.
154+
155+
## Unresolved Questions
156+
157+
<!-- What parts of the proposal do you expect to resolve before this gets accepted? -->
158+
<!-- What parts of the proposal need to be resolved before the proposal is stabilized? -->
159+
<!-- What related issues would you consider out of scope for this proposal but can be addressed in the future? -->
160+
161+
No questions have been identified.
162+
163+
## Future Possibilities
164+
165+
<!-- What future possibilities can you think of that this proposal would help with? -->
166+
167+
- `LocalsCommandRunner` could be enhanced to support Cancellation.
168+
This would allow the modal dialog shown from our USX command to provide a `Cancel` button in case the user decides not to wait on a large delete operation to complete and block usage of VS.
169+
Considerations need to be made around this cancellation resulting in a partial restore and its effect on No-Op restore (see https://github.com/NuGet/Home/issues/13191).
9.44 KB
Loading
61.1 KB
Loading

0 commit comments

Comments
 (0)