Skip to content

Decouple extension version reporting from MTP AppVersion using MSBuild-generated build info while preserving CrashDump forward compatibility#7743

Open
Copilot wants to merge 15 commits intomainfrom
copilot/fix-mtp-appversion-usage
Open

Decouple extension version reporting from MTP AppVersion using MSBuild-generated build info while preserving CrashDump forward compatibility#7743
Copilot wants to merge 15 commits intomainfrom
copilot/fix-mtp-appversion-usage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Extensions were reporting Version via Microsoft.Testing.Platform.Helpers.AppVersion.DefaultSemVer (through IVT), which incorrectly ties extension version identity to the loaded MTP version. This breaks version accuracy when extension and platform versions differ.

  • Version source correction (extension-local, not platform-local)

    • Added a shared ExtensionVersion helper linked into each affected extension assembly.
    • Switched extension version resolution to the same MSBuild build-info template technique used by the core platform:
      • enabled <GenerateBuildInfo>true</GenerateBuildInfo> in each affected extension project
      • added BuildInfo.cs.template that generates an extension-local version constant at build time
    • Version properties now resolve from generated extension build info (ExtensionBuildVersion.Version) instead of AppVersion.DefaultSemVer.
  • CrashDump forward-compatibility adjustment

    • Kept InternalsVisibleTo from Microsoft.Testing.Platform to Microsoft.Testing.Extensions.CrashDump.
    • This is required for forward compatibility with previously shipped CrashDump extension binaries that still access platform internals at runtime.
  • Touched extension areas

    • AzureDevOpsReport
    • CrashDump
    • HangDump
    • MSBuild
    • Retry
    • TrxReport
    • VSTestBridge
  • Focused regression coverage

    • Added unit tests asserting representative extension providers read version from their own extension-local source rather than MTP AppVersion.
internal static class ExtensionVersion
{
    public const string DefaultSemVer = ExtensionBuildVersion.Version;
}

// before: public string Version => AppVersion.DefaultSemVer;
public string Version => ExtensionVersion.DefaultSemVer;

Copilot AI requested review from Copilot and removed request for Copilot April 17, 2026 09:55
Copilot AI linked an issue Apr 17, 2026 that may be closed by this pull request
Copilot AI requested review from Copilot and removed request for Copilot April 17, 2026 10:14
Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/b1573313-b7dd-4dca-a827-51d1ada1e918

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 17, 2026 10:15
Copilot AI changed the title [WIP] Fix MTP AppVersion bug in extensions Decouple extension version reporting from MTP AppVersion and remove CrashDump IVT dependency Apr 17, 2026
Copilot AI requested a review from Evangelink April 17, 2026 10:18
@Evangelink
Copy link
Copy Markdown
Member

@copilot pipeline is red, please fix issues

Copilot AI requested review from Copilot and removed request for Copilot April 17, 2026 12:17
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

@copilot pipeline is red, please fix issues

Pushed a fix in 19b6c12 to address the pipeline issue path: I added an explicit System.Reflection import in ExtensionVersionTests and revalidated with warnings-as-errors build plus targeted extensions unit tests (all passing). Please re-run the PR pipeline on latest commit 19b6c12.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dev.azure.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Evangelink
Copy link
Copy Markdown
Member

@copilot there is a test failure:

Check failure on line 665 in src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs

@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Linux Debug)
src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs#L665

src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs(665,1): error : [NewerPlatform_WithPreviousExtensions_ShouldExecuteTests] [net11.0] Assert.AreEqual failed. Expected:<0>. Actual:<1>. 'expected' expression: 'exitCode', 'actual' expression: 'testHostResult.ExitCode'. Expression 'AssertExitCodeIs' failed for member 'NewerPlatform_WithPreviousExtensions_ShouldExecuteTests' at line 17 of file '/_/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/ForwardCompatibilityTests.cs'. Output of the test host is:
Command: /mnt/vss/_work/1/s/artifacts/tmp/Debug/testsuite/fKP7l/ForwardCompatibilityTest/bin/Release/net10.0/ForwardCompatibilityTest --crashdump --hangdump --report-trx --retry-failed-tests 3

ExitCode: 1

StandardOutput:
Microsoft.Testing.Platform v2.3.0-ci (UTC 04/17/2026) [linux-x64 - net10.0]
Test host process exited before the retry service could connect to it. Exit code: 134

StandardError:
Unhandled exception. System.MethodAccessException: Attempt by method 'Microsoft.Testing.Extensions.CrashDumpExtensions+<>c__DisplayClass0_0.b__0(System.IServiceProvider)' to access method 'Microsoft.Testing.Platform.Services.ServiceProviderExtensions.GetTestApplicationModuleInfo(System.IServiceProvider)' failed.
at Microsoft.Testing.Extensions.CrashDumpExtensions.<>c__DisplayClass0_0.b__0(IServiceProvider serviceProvider) in //src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpExtensions.cs:line 32
at Microsoft.Testing.Platform.TestHostControllers.TestHostControllersManager.BuildAsync(ServiceProvider serviceProvider) in /
/src/Platform/Microsoft.Testing.Platform/TestHostControllers/TestHostControllersManager.cs:line 120
at Microsoft.Testing.Platform.Hosts.TestHostBuilder.BuildAsync(ApplicationLoggingState loggingState, TestApplicationOptions testApplicationOptions, IUnhandledExceptionsHandler unhandledExceptionsHandler, DateTimeOffset createBuilderStart) in //src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs:line 447
at Microsoft.Testing.Platform.Builder.TestApplicationBuilder.BuildAsync() in /
/src/Platform/Microsoft.Testing.Platform/Builder/TestApplicationBuilder.cs:line 120
at Program.Main(String[] args) in /mnt/vss/_work/1/s/artifacts/tmp/Debug/testsuite/fKP7l/ForwardCompatibilityTest/Program.cs:line 26
at Program.

(String[] args)

Copilot AI requested review from Copilot and removed request for Copilot April 17, 2026 18:02
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 17, 2026

@copilot there is a test failure:

[Check failure on line 665 in src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs](https://github.com/microsoft/testfx/pull/7743/files#annotation_5188211...

Fixed in e9afe78: restored InternalsVisibleTo from Microsoft.Testing.Platform to Microsoft.Testing.Extensions.CrashDump to preserve forward compatibility with previous CrashDump extension binaries and avoid the reported MethodAccessException path. I also validated targeted builds/tests locally; the specific forward-compatibility test could not be fully executed in this sandbox due transient package-feed download failures (Resource temporarily unavailable) when restoring 2.2.1 extensions.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 11vvsblobprodcus336.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/kiCDy/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
  • 1k9vsblobprodcus379.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/kiCDy/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
  • 7k6vsblobprodcus337.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/kiCDy/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
  • 7tjvsblobprodcus341.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/kiCDy/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
  • 80zvsblobprodcus35.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/kiCDy/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
  • cflvsblobprodcus383.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/kiCDy/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)
  • jrqvsblobprodcus343.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx//.dotnet/dotnet /home/REDACTED/work/testfx/testfx//.dotnet/dotnet build /home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/qOqzx/ForwardCompatibilityTest -c Release -p:MSBuildTreatWarningsAsErrors=true -p:TreatWarningsAsErrors=true -p:SuppressNETCoreSdkPreviewMessage=true -bl:/home/REDACTED/work/testfx/testfx/artifacts/tmp/Debug/testsuite/ForwardCompatibilityTest-1.binlog (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Decouple extension version reporting from MTP AppVersion and remove CrashDump IVT dependency Decouple extension version reporting from MTP AppVersion while preserving CrashDump forward compatibility Apr 17, 2026
@Evangelink Evangelink enabled auto-merge April 20, 2026 09:38
@Evangelink
Copy link
Copy Markdown
Member

@copilot let's avoid reflection and instead ujse the same technic as the core platform (with the msbuild template)

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot let's avoid reflection and instead ujse the same technic as the core platform (with the msbuild template)

Done in 9dd19c3: I removed the reflection-based extension version lookup and switched to the same MSBuild template pattern as the core platform (BuildInfo.cs.template + GenerateBuildInfo=true) for the affected extensions. ExtensionVersion now reads from generated ExtensionBuildVersion.Version.

Copilot AI changed the title Decouple extension version reporting from MTP AppVersion while preserving CrashDump forward compatibility Decouple extension version reporting from MTP AppVersion using MSBuild-generated build info while preserving CrashDump forward compatibility Apr 20, 2026
Comment thread src/Platform/SharedExtensionHelpers/ExtensionVersion.cs Outdated
Comment thread src/Platform/SharedExtensionHelpers/ExtensionVersion.cs Outdated
Comment thread src/Platform/Microsoft.Testing.Extensions.VSTestBridge/BuildInfo.cs.template Outdated
Comment thread src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/BuildInfo.cs.template Outdated
…rsion wrapper

- Move BuildInfo.cs.template to SharedExtensionHelpers/ as a single shared copy
- Add BuildInfoTemplateFile property in Directory.Build.targets to allow
  overriding the template path (defaults to MSBuildProjectDirectory)
- Extension csproj files now set BuildInfoTemplateFile to the shared template
- Template now generates ExtensionVersion.DefaultSemVer directly, eliminating
  the unnecessary ExtensionBuildVersion -> ExtensionVersion const indirection
- Remove #pragma warning disable for IDE0073; use correct file header directly
- Remove per-extension BuildInfo.cs.template duplicates (7 files)
- Remove SharedExtensionHelpers/ExtensionVersion.cs wrapper
Copilot AI review requested due to automatic review settings April 20, 2026 19:11
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.

Copilot's findings

  • Files reviewed: 36/36 changed files
  • Comments generated: 3

Comment thread Directory.Build.targets
Comment thread src/Platform/SharedExtensionHelpers/BuildInfo.cs.template Outdated
…tal build, and test metadata stripping

- Remove namespace declaration from SharedExtensionHelpers/BuildInfo.cs.template to align with existing templates (PlatformVersion, MSTestVersion, etc.) that use global namespace
- Move BuildInfoTemplateFile default outside GenerateVersionSourceFile target for proper incremental evaluation and add template file to Inputs so template changes trigger regeneration
- Strip +metadata from AssemblyInformationalVersion in tests since ExtensionVersion.DefaultSemVer comes from $(Version) (semver only)
Copilot AI review requested due to automatic review settings April 21, 2026 11:06
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.

Copilot's findings

  • Files reviewed: 67/67 changed files
  • Comments generated: 6

Comment thread test/Utilities/Microsoft.Testing.TestInfrastructure/TempDirectory.cs Outdated
…x for test infrastructure

The test infrastructure project uses ExtensionVersion.DefaultSemVer to specify
the Microsoft.Testing.Platform package version in generated test projects.
Since the project lives under test/Utilities (not src/Platform), its VersionPrefix
defaults to the MSTest version (4.3.0) instead of the platform version (2.3.0),
causing NU1102 errors when tests try to resolve Microsoft.Testing.Platform 4.3.0-ci.

Override VersionPrefix to TestingPlatformVersionPrefix so the generated version
matches the actual platform package version.
Copilot AI review requested due to automatic review settings April 21, 2026 17:00
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.

Copilot's findings

  • Files reviewed: 71/71 changed files
  • Comments generated: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MTP AppVersion shouldn't be used via IVT by extensions

4 participants