Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 4.68 KB

package-source-mapper-VS.md

File metadata and controls

77 lines (50 loc) · 4.68 KB

Package Source Mapper in Visual Studio

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. The tool is reading the solution's package graph.
  2. The tool is calculating the source mappings to create.
  3. 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.
    2. 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

  • Import the relevant source code into VS from the 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

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