extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Overhaul project template builds and testing

Open jeffhandley opened this issue 3 weeks ago • 0 comments

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 avatar Dec 08 '25 08:12 jeffhandley