-
Notifications
You must be signed in to change notification settings - Fork 849
Overhaul project template builds and testing #7113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul project template builds and testing #7113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR performs a comprehensive overhaul of the project template build system and testing infrastructure. The primary goal is to improve maintainability by:
- Moving template content generation from MSBuild-generated files in
/srcto packaged NuGet content with version tokens replaced during build - Consolidating snapshot and execution tests into reusable base classes with parameterized tests
- Renaming template projects to align with template names (e.g.,
ChatWithCustomData-CSharp→AIChatWeb-CSharp) - Excluding
wwwrootstatic content fromaichatwebsnapshots to avoid large binary files in snapshots - Outputting all test artifacts to
/artifacts/ProjectTemplates/for improved discoverability
Reviewed changes
Copilot reviewed 115 out of 497 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
test/ProjectTemplates/**/*.cs |
Refactored snapshot and execution tests to use base classes and Theory tests; removed project-specific helper classes |
test/ProjectTemplates/Infrastructure/* |
Added reusable test utilities, base classes, and updated well-known paths to artifacts folder |
src/ProjectTemplates/Directory.Build.targets |
Added MSBuild task to generate template content with package version token replacement |
src/ProjectTemplates/Microsoft.*.Templates.csproj |
Updated to use TemplatePackageVersion items and TemplateContent preprocessing instead of generated content references |
src/ProjectTemplates/**/templates/** |
Renamed from src/* folders; changed .csproj files to .csproj-in with version tokens; updated namespace/project references |
src/ProjectTemplates/GeneratedContent.targets |
Removed file that defined template content generation with hardcoded versions |
test/ProjectTemplates/**/Snapshots/** |
Removed wwwroot folders from snapshots; updated snapshot naming scheme and placeholder tokens |
src/ProjectTemplates/README.md |
Updated documentation for new build process and template content generation |
9e657dc to
a5a9dfd
Compare
...ctTemplates/Microsoft.Agents.AI.ProjectTemplates/Microsoft.Agents.AI.ProjectTemplates.csproj
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj
Outdated
Show resolved
Hide resolved
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.csproj
Show resolved
Hide resolved
7b3c113 to
20eacea
Compare
59442bf to
2894d13
Compare
ericstj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed infrastructure and left a couple comments I trust you can address. I'm assuming test coverage is correct.
For things like this where we overhaul infrastructure I suggest diffing the outputs before/after to ensure the diff makes sense.
1. Remove unused AllowExplicitReference property on PackageReference 2. Remove SetTargetFramework to avoid possible unintended side effects 3. Simplify how the replacement properties are passed in for template content Also tighten up the Snapshot test AddPackageReferenceScrubber helper to ensure it only replaces version strings so that bugs in the MSBuild replacement logic that produce unexpected replacement strings do not get matched. This ensures the Snapshot tests fail if the version replacement logic is broken. As part of that, the scrubber helpers were moved into the VerifyScrubbers.cs file.
This pull request overhauls the way project template content is generated, how package versions are resolved for template projects, and how project template snapshot and execution tests are run.
The following goals are achieved, with the theme of substantially improving template maintenance:
/srcfolder during project template build, pack, or testingsrc, simplifying the projects and template infrastructure<ProjectReference />and<PackageVersion />items, with<PackageVersion />items for external packages defined in theDirectory.Packages.props-based imports<ProjectReference />-resolved version for a package within the repository, a template project can simply add<PackageVersion Update="Microsoft.Extensions.AI" Version="10.0.0" />(e.g.) into the project file. Otherwise, no template-specific versions need to be defined.[Theory]tests over the combinations of options to be tested-CSharpfolders was collapsed-CSharpname is still useful for a couple reasons, most importantly that this is part of thesourceNameused within the project template string replacement logic. When the-CSharpsuffix is removed, there are unintended matches on the tokens throughout the project template content./artifactsfolder during build and test, making them more discoverable and easier to navigate during development and testing. Runningcleanfor a template project will delete its/artifacts/ProjectTemplatesfolder./srcfolder, producing results that match the packed project templatenetstandard2.0rather than building multiple times against each target frameworkwwwrootfolder with its static contentDevelopment documentation was updated to reflect all of the changes.
The PR is broken into 6 commits, removing and readding the snapshots in commits flanking the actual overhaul work. There are two stages to the overhaul.
<TemplatePackageVersion />items that specifiedProjectand/orVersionproperties, with the versions defined within the template projects.<ProjectReference />and<PackageVersion />items to resolve the versions needed for the project templates. This iteration also addresses other MSBuild- and dev-innerloop-related feedback.While git isn't showing the snapshot changes as simple renames, there were not any functional changes to them. The changes to the snapshots reflect:
wwwrootfoldersThis PR is made ahead of other upcoming work on the project templates, where these changes will make it more straightforward to:
Microsoft Reviewers: Open in CodeFlow