Skip to content

v8.0.132

@marcpopMSFT marcpopMSFT tagged this 17 Sep 23:23
Enable package source mapping for dotnet new install

----
#### AI description  (iteration 1)
#### PR Classification
New feature: Adds support for NuGet package source mapping to filter and validate package sources when installing templates via `dotnet new install`.

#### PR Summary
This PR implements package source mapping support in the NuGet package manager, allowing the template engine to respect NuGet's package source mapping configuration and filter package sources accordingly. When enabled, only mapped sources are used for package installation, and an error is thrown if no mapping is found for a package.

- `NugetApiPackageManager.cs`: Refactored `LoadNuGetSources()` to accept package identifier parameter and filter sources based on NuGet's `PackageSourceMapping` configuration
- `PackageNotFoundException.cs`: Added `PackageSourceMappingMatchNotFound` property to distinguish errors when package source mapping is enabled but no matching source is found
- `NuGetApiPackageManagerTests.cs`: Added 8 comprehensive unit tests covering exact mapping, wildcard patterns, multiple mapped sources, disabled sources, and additional source handling
- `LocalizableStrings` files: Added new error message `NuGetInstaller_Error_PackageSourceMappingMatchNotFound` for when package source mapping is enabled but no source matches the package
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Assets 2
Loading