Skip to content

Merge dotnet/templating into dotnet/sdk (Phase 2: build integration and ProjectReference conversion)#53680

Merged
MichaelSimons merged 54 commits intodotnet:mainfrom
MichaelSimons:merge-templating-phase2
Apr 17, 2026
Merged

Merge dotnet/templating into dotnet/sdk (Phase 2: build integration and ProjectReference conversion)#53680
MichaelSimons merged 54 commits intodotnet:mainfrom
MichaelSimons:merge-templating-phase2

Conversation

@MichaelSimons
Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons commented Apr 2, 2026

Phase 2 of the dotnet/templating → dotnet/sdk merge. Phase 1 (#53647) brought in the source files with preserved commit history. This phase integrates the TemplateEngine projects into the SDK build system.

Changes

Dependency removal

  • Remove dotnet/templating external package dependency entries from eng/Version.Details.xml and Directory.Packages.props

Build infrastructure

  • Add TemplateEngine package versions and signing configuration
  • Define TemplateEngSrcDir, TemplateEngTestDir, and TemplateEngTestAssetsDir properties for consistent path references across the build

ProjectReference conversion

  • Convert TemplateEngine PackageReferences to ProjectReferences so the SDK builds the TemplateEngine source directly instead of consuming pre-built packages

Solution integration

  • Add TemplateEngine projects to sdk.slnx
  • Add TemplateEngine projects to TemplateEngine solution filter
  • Add TemplateEngine src and template_feed projects to source-build.slnf

xUnit v3 migration

  • Migrate all TemplateEngine test projects from xUnit v2 to xUnit v3. No external consumers of the v2 projects were detected outside of the SDK repo.
  • Remove the following XunitV3 variant projects that were created as transitional duplicates and are no longer needed:
    • Microsoft.TemplateEngine.Mocks.XunitV3
    • Microsoft.TemplateEngine.TestHelper.XunitV3
    • Microsoft.TemplateEngine.Authoring.TemplateVerifier.XunitV3
    • Microsoft.TemplateEngine.Authoring.TemplateApiVerifier.XunitV3
    • Microsoft.TemplateEngine.Authoring.TemplateVerifier.IntegrationTests.XunitV3
    • Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests.XunitV3

Test infrastructure

  • Integrate TemplateEngine test projects with the SDK's Helix test infrastructure
  • Fix test project discovery globs and build compatibility issues

Related

Directory.Packages.props:
- Added FakeItEasy, JsonSchema.Net, Verify.*, xunit V3 packages
- Added Microsoft.IO.Redist, NuGet.Credentials
- Set StyleCop.Analyzers to explicit version 1.2.0-beta.556
- Added xunit.abstractions, xunit.extensibility.execution

eng/Signing.props:
- Added TemplateEngine non-shipping packages to signing exclusion list
Added src/TemplateEngine/Directory.Build.props:
- Chains to repo root props via GetPathOfFileAbove
- StrongNameKeyId: MicrosoftAspNetCore
- GenerateDocumentationFile: true
- StyleCop.Analyzers + PublicApiAnalyzers package references
- Suppressed RS0016/RS0041 (Public API analyzer version differences)
- Suppressed NU5105/NU5128/NU5100/NU5118/0419/0649

Added src/TemplateEngine/.editorconfig:
- Migrated StyleCop rule suppressions from dotnet/templating
- Downgraded IDE0005 to suggestion (multi-target implicit usings conflict)

Root Directory.Build.props:
- Added TemplateEngineRoot, TemplatesDir, NetFrameworkMinimum properties

Updated all TE csproj/props files:
- Replaced $(SrcDir) with $(TemplateEngineRoot)
- Replaced $(ToolsDir) with $(TemplateEngineRoot)Tools/
- Replaced $(TestDir) with $(RepoRoot)test/TemplateEngine/
Now that TemplateEngine source is in-repo, convert external package
references to in-tree project references:

src/Cli/Microsoft.TemplateEngine.Cli:
- Microsoft.TemplateEngine.Edge → ProjectReference
- Microsoft.TemplateSearch.Common → ProjectReference

src/Cli/dotnet:
- Microsoft.TemplateEngine.Orchestrator.RunnableProjects → ProjectReference

test/Microsoft.TemplateEngine.Cli.UnitTests:
- Microsoft.TemplateEngine.Mocks → ProjectReference
- Microsoft.TemplateEngine.TestHelper → ProjectReference
- Microsoft.TemplateEngine.Orchestrator.RunnableProjects → ProjectReference

test/dotnet-new.IntegrationTests:
- Microsoft.TemplateEngine.TestHelper → ProjectReference
- Microsoft.TemplateEngine.Authoring.TemplateVerifier → ProjectReference

test/dotnet.Tests:
- Microsoft.TemplateEngine.Mocks → ProjectReference
- Microsoft.TemplateEngine.TestHelper → ProjectReference
Added /src/TemplateEngine/ folder with 8 source projects
Added /src/TemplateEngine/Tools/ folder with 8 tool projects
Added 19 TemplateEngine test projects to /test/ folder
test/Directory.Build.props:
- Added _IsTemplateEngineTestProject detection property
- StrongNameKeyId: MicrosoftAspNetCore for TE test projects (InternalsVisibleTo)
- GenerateProgramFile: true for TE test projects (different test runner)
- Suppressed IDE0005, CS0649, CA2016, CA5394, CA1802 for TE tests

test/Directory.Build.targets:
- Scoped FluentAssertions/TestFramework global usings to non-TE tests
- Scoped Common/Program.cs inclusion to non-TE tests
- TE test projects get minimal Xunit global using only

test/UnitTests.proj:
- Added TemplateEngine test template assets for Helix payload
- Removed duplicate PackageVersion entries (FakeItEasy, Verify.DiffPlex,
  Verify.XUnit) that conflicted with eng/dependabot/Packages.props
- Bumped Microsoft.IO.Redist 6.0.1 → 6.1.0 (MSBuild transitive dependency)
- Restored Microsoft.DotNet.Build.Tasks.Templating (Arcade package, not TE)
  to Version.Details.xml, Version.Details.props, and Directory.Packages.props
- Fixed template.json schema path in RunnableProjects.UnitTests to use
  $(TemplateEngineRoot) instead of $(SolutionDir)
- Fixed Authoring.Tasks.IntegrationTests Compile include to use
  $(TemplateEngineRoot)Tools\Shared instead of broken relative path
- Move NetFrameworkMinimum override from repo root to TemplateEngine scope
- Remove signing exclusions from eng/Signing.props (Arcade handles non-shipping)
- Inline package versions alphabetically in Directory.Packages.props
- Fix Version.Details.xml formatting
- Restore full .editorconfig (rules aren't covered by root editorconfig)
- Remove redundant ExcludeFromSourceOnlyBuild (inherited from parent)
- Move TemplateEngine test config into test/TemplateEngine/Directory.Build.props
  and test/TemplateEngine/Directory.Build.targets
- Restore test/Directory.Build.props and test/Directory.Build.targets to original
  state (no TE-specific conditioning)
- Remove only the global usings that TE tests don't reference
  (FluentAssertions, Microsoft.NET.TestFramework.*)
- Inline TemplateEngineRoot/TemplatesDir properties in Directory.Build.props
- Add TODO comment for RS0016/RS0041 PublicAPI analyzer suppression
- Simplify test/TemplateEngine/Directory.Build.targets
- Update TemplateEngine.slnf to be a filter over sdk.slnx
- Remove stale Microsoft.TemplateEngine.sln
- Restore all original projects in TemplateEngine.slnf that were
  inadvertently removed (Win32.Msi, NativeWrapper, SdkResolver,
  TemplateLocator.Tests)
- Add template_feed/Microsoft.TemplateEngine.Authoring.Templates to slnf
- Add TODO comments for migrating NetFrameworkMinimum to
  NetFrameworkToolCurrent in both src and test Directory.Build.props
Add TemplateEngineTestRoot property in Directory.Build.props pointing to
test\TemplateEngine\. Replace all test/TemplateEngine/ references
in csproj files with  for consistency with the
 pattern used for source projects.
Replace relative paths (..\TemplateEngine\...) with
in dotnet-new.IntegrationTests, dotnet.Tests, and Cli.UnitTests for
consistency with TE-internal project references.
- Add Directory.Build.props/targets in test_templates/ to opt out of CPM
  (test templates are test assets with hardcoded PackageReference versions)
- Fix TemplateEngineTestAssets paths in UnitTests.proj to include the
  TemplateEngine/ subdirectory prefix
- Add TemplateEnginePublicKey, DynamicProxyGenAssembly2PublicKey, and
  Deterministic properties to src/TemplateEngine/Directory.Build.props
  (brought forward from the templating repo)
- Fix MockTemplateInfo obsolete interface properties to return empty
  collections instead of throwing NotImplementedException, which is
  incompatible with System.Text.Json serialization
The Newtonsoft → System.Text.Json migration changed the error message
format when parsing corrupted JSON settings files. Update the Verify
snapshots to match the new STJ exception message.
The Helix layout was copying TemplateEngine test templates into
TestAssets/TestPackages/dotnet-new/, overwriting the SDK's standalone
Microsoft.TemplateEngine.TestTemplates.csproj (which has net6.0
hardcoded) with the TemplateEngine version (which uses $(NetCurrent)).
On Helix, $(NetCurrent) is undefined, causing dotnet pack to fail with
NETSDK1013.

Move TemplateEngine test assets to their own TestAssets/TestPackages/
TemplateEngine/ directory in the Helix payload to avoid clobbering the
SDK's dotnet-new test assets.
@MichaelSimons MichaelSimons force-pushed the merge-templating-phase2 branch from c13875a to 4d7495b Compare April 3, 2026 19:23
…ase2

# Conflicts:
#	Directory.Packages.props
#	eng/Version.Details.xml
#	test/Microsoft.TemplateEngine.Cli.UnitTests/Microsoft.TemplateEngine.Cli.UnitTests.csproj
#	test/dotnet-new.IntegrationTests/dotnet-new.IntegrationTests.csproj
#	test/dotnet.Tests/dotnet.Tests.csproj
The following projects were duplicated with XunitV3 suffixes to support
xunit v3 testing while the main codebase was still on xunit v2. Now that
the xunit v3 migration is complete, the originals are v3 and these
variants are redundant:

- Microsoft.TemplateEngine.Mocks.XunitV3
- Microsoft.TemplateEngine.TestHelper.XunitV3
- Microsoft.TemplateEngine.Authoring.TemplateVerifier.XunitV3
- Microsoft.TemplateEngine.Authoring.TemplateApiVerifier.XunitV3
- Microsoft.TemplateEngine.Authoring.TemplateVerifier.IntegrationTests.XunitV3
- Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests.XunitV3

Verified no other repos in the VMR reference the v2 variants.
Now that the SDK repo has completed the xunit v3 migration, update
the original templating engine projects to use xunit v3 directly:

  keeping only the v3 code paths
- Replace xunit v2 package references with v3 equivalents:
  - xunit.abstractions -> xunit.v3.extensibility.core
  - xunit.extensibility.execution -> xunit.v3.extensibility.core
  - Xunit -> xunit.v3.assert + xunit.v3.extensibility.core
  - Verify.Xunit / Verify.XUnit -> Verify.XunitV3
- Update using Xunit.Abstractions -> using Xunit / using Xunit.Sdk
- Implement additional ITestOutputHelper members (Write, Output)
  required by xunit v3 in TestOutputLogger
- Remove dead DummyMethod from VerificationEngine.cs
- Update Verify.XunitV3 version to 28.12.0 in dependabot/Packages.props
Copilot and others added 4 commits April 15, 2026 14:15
…context

These tests run the CLI tool as a subprocess which calls Verifier.VerifyDirectory()
from Verify.XunitV3. Without an xUnit test runner in the subprocess,
TestContext.TestMethod is null causing exit code 70 instead of 65.

dotnet#53889

Co-authored-by: Copilot <[email protected]>
Add ApprovalsDirectory and SnapshotsDirectory properties to TestBase
so all test projects use a single definition instead of repeating
Path.Combine(AppContext.BaseDirectory, ...) at every call site.

Co-authored-by: Copilot <[email protected]>
Replace raw AppContext.BaseDirectory + test_templates path with the
existing TestBase helper property for consistency.

Co-authored-by: Copilot <[email protected]>
- Add SetupNuGetConfigForPackagesLocation helper to TestBase
- Remove unnecessary TestTemplates ProjectReferences (CLI, TemplateVerifier,
  TemplateLocalizer) — tests access templates via TestBase.TestTemplatesLocation
- TemplateLocalizer: link Shared/TestBase.cs and use TestTemplatesLocation
- Reduce Directory.Build.targets Using removes from 6 to 2 (only the ones
  with actual type conflicts remain)

Co-authored-by: Copilot <[email protected]>
Copilot and others added 2 commits April 15, 2026 19:01
The SampleDogfoodTest uses UniqueFor=Architecture but only x64 snapshots
existed, causing verification failures on macOS arm64 Helix workers.

Co-authored-by: Copilot <[email protected]>
$(Version) is empty when the GeneratedText property is evaluated because
SDK versioning targets haven't been imported yet. Use a placeholder in
GeneratedText and substitute $(Version) inside the AddGeneratedFile
target where it is available.

Co-authored-by: Copilot <[email protected]>
…ility

This project targets netstandard2.0, but the latest NuGet packages used
by the rest of the SDK have dropped netstandard support. VersionOverride
pins these to an older netstandard-compatible version.

Co-authored-by: Copilot <[email protected]>
@MichaelSimons
Copy link
Copy Markdown
Member Author

@NikolaMilosavljevic - This is ready for review now. The last PR validation passed with the exception of a number of known failures in main.

Copy link
Copy Markdown
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

Copilot reviewed 104 out of 104 changed files in this pull request and generated 3 comments.

Comment thread Directory.Build.props Outdated
Comment thread test/TemplateEngine/Directory.Build.props Outdated
MichaelSimons and others added 5 commits April 16, 2026 09:55
The TemplateEngine test Directory.Build.props was overriding GenerateProgramFile
to true, but this is unnecessary because xUnit v3's _XunitGenerateEntryPoint
target automatically generates the entry point for test projects. This aligns
TemplateEngine tests with the rest of the SDK test projects which rely on
the repo-root setting of GenerateProgramFile=false.

Co-authored-by: Copilot <[email protected]>
The Approvals files were included as both Content and None items. The Content
include is redundant since the None include with CopyToOutputDirectory is
sufficient to copy files to the output directory.

Co-authored-by: Copilot <[email protected]>
Comment thread src/TemplateEngine/Directory.Build.props
Replace inline Path.Combine(AppContext.BaseDirectory, "Snapshots") with
TestBase.SnapshotsDirectory to be consistent with the IntegrationTests project.
Added Shared file compilation to the UnitTests Shared.props to make TestBase
accessible.

Co-authored-by: Copilot <[email protected]>
Comment thread eng/Version.Details.props
@MichaelSimons
Copy link
Copy Markdown
Member Author

/ba-g all known failures.

@MichaelSimons MichaelSimons merged commit 8c40edb into dotnet:main Apr 17, 2026
18 of 24 checks passed
@MichaelSimons MichaelSimons deleted the merge-templating-phase2 branch April 17, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants