Overhaul project template builds and testing
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:
- No changes occur within the
/srcfolder during project template build, pack, or testing - 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
- 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 theDirectory.Packages.props-based imports - 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. - Snapshot and Execution test code is refactored for reusability and deduplication
- Snapshot and Execution tests are implemented as
[Theory]tests over the combinations of options to be tested - Project template projects are renamed for alignment with the template names
- The parent folder above the
-CSharpfolders was collapsed - Note the
-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.
- The parent folder above the
- GeneratedContent, Snapshots, and execution test Sandbox content is emitted into the
/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. - Snapshot names (and Execution test names) are produced from the project template args, with abbreviated names to avoid path length limits.
- Snapshot tests run against the packaged project templates instead of against the
/srcfolder, producing results that match the packed project template - 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
- Project template projects now only build against
netstandard2.0rather than building multiple times against each target framework - AIChatWeb snapshots now exclude the
wwwrootfolder 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.
- The first was before receiving PR feedback where the template infrastructure was relying on
<TemplatePackageVersion />items that specifiedProjectand/orVersionproperties, with the versions defined within the template projects. - 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:
- Renaming all of the snapshots based on the new naming scheme produced from the args
- Changing the placeholder values for package version numbers and localhost port numbers
- Deletion of the
wwwrootfolders
This PR is made ahead of other upcoming work on the project templates, where these changes will make it more straightforward to:
- 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
- Pull the mcpserver template out into a new package (Microsoft.McpServer.ProjectTemplates) while reusing the template infrastructure
- Add a local/remote option to the mcpserver template with augmented snapshot and execution tests
- Updating aichatweb to the latest version of all dependencies, including JavaScript libraries