Skip to content

[MTP Integration Analysis] Generated *.testconfig.json is left stale when generation is later disabled #8434

@Evangelink

Description

@Evangelink

Summary

GenerateTestingPlatformConfigurationFile only writes $(AssemblyName).testconfig.json when generation is enabled and the source file exists, but it never removes a previously generated output when that condition later becomes false. This leaves stale configuration files in bin/ / publish output.

Evidence

  • src/Platform/Microsoft.Testing.Platform.MSBuild/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets:44-47
    • _GenerateTestingPlatformConfigurationFileCore
    • Condition=" '$(GenerateTestingPlatformConfigurationFile)' == 'true' And Exists('$(_TestingPlatformConfigurationFileSourcePath)') "
  • src/Platform/Microsoft.Testing.Platform.MSBuild/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets:55-62
    • <FileWrites Include="$(_TestingPlatformConfigurationFile)" />
    • <ResolvedFileToPublish Include="$(_TestingPlatformConfigurationFile)" >
  • test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/MSBuildTests.ConfigurationFile.cs:50-72
    • the current regression coverage only checks a fresh build where testconfig.json never existed; it does not cover disabling generation after a file has already been emitted.

Why this is a real issue

If a project builds once with testconfig.json present, then later deletes that file or sets GenerateTestingPlatformConfigurationFile=false, the previously emitted *.testconfig.json stays in the output directory. The test host will keep picking up that stale config on subsequent runs, so build output no longer reflects the current project state.

Suggested resolution

Add an explicit cleanup path when generation is disabled or the source file disappears, and make sure publish items are also removed for that build. Add an integration test that builds once with testconfig.json, removes or disables it, rebuilds, and verifies that the old output file no longer remains in bin/ / publish output.

Related issues

  • None found

Metadata

Metadata

Labels

area/mtp-msbuildMTP MSBuild integration.type/automationCreated or maintained by an agentic workflow.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions