Remove cgmanifest.json and save packages dynamically #49538
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces changes to streamline component governance tracking and enhance integration tests for
dotnet-new
. The most significant updates include removing thecgmanifest.json
file, adding a mechanism to record package references during tests, and implementing a new helper method for extracting package information from project files.Component Governance Updates:
cgmanifest.json
file, which previously tracked component registrations for NuGet packages. This change simplifies the repository by eliminating manual component governance tracking.Integration Test Enhancements:
RecordPackages
, to extract and save package references from.csproj
,.fsproj
, and.vbproj
files into apackages.json
file during test execution. This ensures that package usage is automatically recorded for component governance.ItemTemplate_CanBeInstalledAndTestArePassing
,ProjectTemplate_CanBeInstalledAndTestsArePassing
, andMSTestAndPlaywrightProjectTemplate_WithCoverageToolAndTestRunner_Can
) to callRecordPackages
after executingdotnet new
. This integrates package recording into the test workflow. [1] [2] [3]Codebase Improvements:
CgPackagesJsonPath
as a static readonly field to define the path for the newpackages.json
file, centralizing its location for easier management.using
directives forSystem.Text.Json
andSystem.Text.RegularExpressions
to support JSON serialization and regex operations in theDotnetNewTestTemplatesTests
file.The tests I added generate test projects using dotnet new, but these are eventually deleted and placed in the artifacts folder. By the time the CG step in the pipeline runs, those projects are already gone—and the artifacts folder is excluded from processing anyway.
So I had two options:
I went with option 2 to keep things clean and avoid polluting the repo with temporary test projects.