-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Improve maintainability of dotnet-new.IntegrationTests template package version lists
Problem
The dotnet-new.IntegrationTests project requires manual updates every time a new .NET version is added or an old version reaches end-of-life. There are three tightly-coupled locations that must be kept in sync:
PackageReferenceitems in the.csproj— each supported version ofMicrosoft.DotNet.Common.ProjectTemplatesandMicrosoft.DotNet.Web.ProjectTemplatesis listed individually (currently 6.0 through 10.0).- Generated
TemplatePackagesPathsclass — a code-gen block in the.csprojthat emits aconst stringfor each package's resolved path, also listed individually. - Test code in
SharedHomeDirectory.csandWebProjectsTests.cs— each version is installed/referenced by its specific const, requiring a new block of code per version.
When .NET 11.0 ships, at least 10 lines across these three locations need to be added. When a version goes out of support (e.g., 6.0), lines need to be removed. This is error-prone and easy to forget.
Proposal
Explore using MSBuild wildcards and item-driven code generation to eliminate the per-version enumeration:
- Use wildcard
PackageReferencepatterns (or an MSBuild item group with a version range) so that adding a new version doesn't require editing the.csproj. For example, a single parameterized item group that iterates over a list of supported versions defined in one place (e.g., a property likeSupportedTemplateVersions=6.0;7.0;8.0;9.0;10.0). - Generate
TemplatePackagesPathsdynamically from the resolvedPackageReferenceitems using an MSBuild target, rather than hardcoding each const. - Replace per-version install calls in test code (
SharedHomeDirectory.cs,WebProjectsTests.cs) with a loop over an array or collection of paths, so adding a version only requires updating the single source-of-truth property/list.
Benefits
- Adding or removing a supported .NET version becomes a single-line change in one location.
- Reduces risk of forgetting to update one of the three coupled locations.
- Prevents test compilation/runtime failures from stale version lists.
Relevant files
Reactions are currently unavailable