From 115f77b15fc713216e05d6d4e26c5953129c0ec9 Mon Sep 17 00:00:00 2001 From: Donnie Goodson <49205731+donnie-msft@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:12:02 -0700 Subject: [PATCH 1/2] Spec: Package Source Mapper in Visual Studio --- accepted/2023/package-source-mapper-VS.md | 81 +++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 accepted/2023/package-source-mapper-VS.md diff --git a/accepted/2023/package-source-mapper-VS.md b/accepted/2023/package-source-mapper-VS.md new file mode 100644 index 000000000..df4372657 --- /dev/null +++ b/accepted/2023/package-source-mapper-VS.md @@ -0,0 +1,81 @@ +# Package Source Mapper in Visual Studio + + +- Donnie Goodson ([donnie-msft](https://github.com/donnie-msft)) +- GitHub Issue + +## Summary + + +Package source mapping is a relatively new feature in the .NET ecosystem, and Visual Studio (VS) doesn't currently have an onboarding experience for existing solutions. Let's bring the `PackageSourceMapper` tool's functionality into Visual Studio by introducing a button to launch the tool via the `NuGet Package Manager` VS Options. The existing `Package Source Mappings` options page can be automatically populated by the tool, and then update the solution's `NuGet.Config` with all package's mapped to the appropriate source. + +## Motivation + + +The vast majority of existing .NET solutions were created prior to package source mapping. Onboarding to the feature can be done manually, but this may be cumbersome for larger solutions with complex graphs. To reduce friction and encourage adoption of security features, the `PackageSourceMapper` tool was created to analyze the graphs and NuGet package sources to generate source mappings. Bringing this tool's functionality into Visual Studio is the next evolution of the onboarding experience. + +## Explanation + +### Functional explanation + + + +Open a solution which has not onboarded to Package Source Mapping. Navigate to the VS Options page, `Package Source Mappings` under `NuGet Package Manager`. In the blank list of source mappings, notice the link, "Create source mappings for this Solution's installed packages". + +If a solution is already onboarded, there will be at least 1 mapping already, and therefore, the link to onboard a solution will not be available. + +Press the link, and a cancellable dialog window will appear indicating the following progress: +1. Loading the `PackageSourceMapper` tool as an external process. +1. The tool is reading the solution's package graph. +1. The tool is calculating the source mappings to create. +1. Results are shown in the dialog, and the Cancel button changes to an OK button. + 1. If any conflicts or errors occurred, those are shown in the dialog. + 1. If successful, a count is shown with a successful status message. After pressing OK, the source mappings are shown in the mappings list. This is the same result as manually adding these mappings. + + + + +### Technical explanation + + +- `PackageSourceMapper` installation to VS + - Optional component? Workload? + - NuGet.Tools.vsix? Separate vsix? +- External process initiated from VS +- VS Option pages already use WPF dialogs which will be the UI to communicate this tool's state. +- Populating the list gives the customer the ability to "consent" to the generated mappings prior to writing creating them. The heavy lifting is behind-the-scenes, but the impact is visible to the customer. +- Writing to the `NuGet.Config` is functionality that's already available from NuGet's VS Option pages. + +## Drawbacks + + +None + +## Rationale and alternatives + + + + + +None + +## Prior Art + + + + + + +The `PackageSourceMapper` tool does the heavy lifting. Customers have used the tool outside of VS successfully, so making it part of VS should build upon that success. + +## Unresolved Questions + + + + +None + +## Future Possibilities + + +None \ No newline at end of file From 3eb3a2733ca5d8881544dd13a7d4ce0d8621719b Mon Sep 17 00:00:00 2001 From: Donnie Goodson <49205731+donnie-msft@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:08:43 -0700 Subject: [PATCH 2/2] Link to issue and tool repository --- accepted/2023/package-source-mapper-VS.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/accepted/2023/package-source-mapper-VS.md b/accepted/2023/package-source-mapper-VS.md index df4372657..053ebc5fb 100644 --- a/accepted/2023/package-source-mapper-VS.md +++ b/accepted/2023/package-source-mapper-VS.md @@ -2,12 +2,12 @@ - Donnie Goodson ([donnie-msft](https://github.com/donnie-msft)) -- GitHub Issue +- GitHub Issue [#12834](https://github.com/NuGet/Home/issues/12834) ## Summary -Package source mapping is a relatively new feature in the .NET ecosystem, and Visual Studio (VS) doesn't currently have an onboarding experience for existing solutions. Let's bring the `PackageSourceMapper` tool's functionality into Visual Studio by introducing a button to launch the tool via the `NuGet Package Manager` VS Options. The existing `Package Source Mappings` options page can be automatically populated by the tool, and then update the solution's `NuGet.Config` with all package's mapped to the appropriate source. +Package source mapping is a relatively new feature in the .NET ecosystem, and Visual Studio (VS) doesn't currently have an onboarding experience for existing solutions. Let's bring the [PackageSourceMapper](https://github.com/NuGet/PackageSourceMapper/tree/dev/PackageSourceMapper) tool's functionality into Visual Studio by introducing a button to launch the tool via the `NuGet Package Manager` VS Options. The existing `Package Source Mappings` options page can be automatically populated by the tool, and then update the solution's `NuGet.Config` with all package's mapped to the appropriate source. ## Motivation @@ -25,7 +25,6 @@ Open a solution which has not onboarded to Package Source Mapping. Navigate to t If a solution is already onboarded, there will be at least 1 mapping already, and therefore, the link to onboard a solution will not be available. Press the link, and a cancellable dialog window will appear indicating the following progress: -1. Loading the `PackageSourceMapper` tool as an external process. 1. The tool is reading the solution's package graph. 1. The tool is calculating the source mappings to create. 1. Results are shown in the dialog, and the Cancel button changes to an OK button. @@ -38,12 +37,9 @@ Press the link, and a cancellable dialog window will appear indicating the follo ### Technical explanation -- `PackageSourceMapper` installation to VS - - Optional component? Workload? - - NuGet.Tools.vsix? Separate vsix? -- External process initiated from VS -- VS Option pages already use WPF dialogs which will be the UI to communicate this tool's state. -- Populating the list gives the customer the ability to "consent" to the generated mappings prior to writing creating them. The heavy lifting is behind-the-scenes, but the impact is visible to the customer. +- Import the relevant source code into VS from the [PackageSourceMapper](https://github.com/NuGet/PackageSourceMapper/tree/dev/PackageSourceMapper) repository. +- VS Options dialog have pages that already use WPF dialogs, which will be the UI to communicate status from the tool. +- Populating the list gives the customer the ability to "consent" to the generated mappings prior to writing them to disk. The heavy lifting is behind-the-scenes, but the impact is visible to the customer. - Writing to the `NuGet.Config` is functionality that's already available from NuGet's VS Option pages. ## Drawbacks