Skip to content

Conversation

@jeffhandley
Copy link
Member

@jeffhandley jeffhandley commented Dec 8, 2025

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:

  1. No changes occur within the /src folder during project template build, pack, or testing
  2. The template projects are no longer directly runnable from within src, simplifying the projects and template infrastructure
    • This allowed for the removal of build infrastructure that previously enabled that
  3. The template build infrastructure is refactored and rearranged to define the template package reference versions using <ProjectReference /> and <PackageVersion /> items, with <PackageVersion /> items for external packages defined in the Directory.Packages.props-based imports
  4. To override a <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.
  5. Snapshot and Execution test code is refactored for reusability and deduplication
  6. Snapshot and Execution tests are implemented as [Theory] tests over the combinations of options to be tested
  7. Project template projects are renamed for alignment with the template names
    • The parent folder above the -CSharp folders was collapsed
    • Note the -CSharp name is still useful for a couple reasons, most importantly that this is part of the sourceName used within the project template string replacement logic. When the -CSharp suffix is removed, there are unintended matches on the tokens throughout the project template content.
  8. GeneratedContent, Snapshots, and execution test Sandbox content is emitted into the /artifacts folder during build and test, making them more discoverable and easier to navigate during development and testing. Running clean for a template project will delete its /artifacts/ProjectTemplates folder.
  9. Snapshot names (and Execution test names) are produced from the project template args, with abbreviated names to avoid path length limits.
  10. Snapshot tests run against the packaged project templates instead of against the /src folder, producing results that match the packed project template
  11. Snapshot test scrubbing is refactored and augmented to fully remove package versions from verified snapshot baselines
    • This results in no longer needing to update snapshots with repo branding updates
  12. Project template projects now only build against netstandard2.0 rather than building multiple times against each target framework
  13. AIChatWeb snapshots now exclude the wwwroot folder with its static content

Development 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.

  1. The first was before receiving PR feedback where the template infrastructure was relying on <TemplatePackageVersion /> items that specified Project and/or Version properties, with the versions defined within the template projects.
  2. The second iteration is after receiving PR feedback, where the template infrastructure uses <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:

  1. Renaming all of the snapshots based on the new naming scheme produced from the args
  2. Changing the placeholder values for package version numbers and localhost port numbers
  3. Deletion of the wwwroot folders

This PR is made ahead of other upcoming work on the project templates, where these changes will make it more straightforward to:

  1. Update the aiagent-webapi template to the latest version of Agent Framework and preparing to update that template on a different cadence from aichatweb
    • This will also address the issue found during this overhaul that the template currently does not work with net8.0, as DevUI did not add support for net8.0 until version 1.0.0-preview.251125.1
  2. Pull the mcpserver template out into a new package (Microsoft.McpServer.ProjectTemplates) while reusing the template infrastructure
  3. Add a local/remote option to the mcpserver template with augmented snapshot and execution tests
  4. Updating aichatweb to the latest version of all dependencies, including JavaScript libraries
Microsoft Reviewers: Open in CodeFlow

@jeffhandley jeffhandley self-assigned this Dec 8, 2025
@jeffhandley jeffhandley requested review from a team as code owners December 8, 2025 08:20
@jeffhandley jeffhandley added the area-ai-templates Microsoft.Extensions.AI.Templates label Dec 8, 2025
Copilot AI review requested due to automatic review settings December 8, 2025 08:20
Copy link
Contributor

Copilot AI left a 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 /src to 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-CSharpAIChatWeb-CSharp)
  • Excluding wwwroot static content from aichatweb snapshots 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

@jeffhandley jeffhandley force-pushed the jeffhandley/template-testing branch from 9e657dc to a5a9dfd Compare December 8, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai-templates Microsoft.Extensions.AI.Templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants