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
Summary
GenerateTestingPlatformConfigurationFileonly writes$(AssemblyName).testconfig.jsonwhen 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 inbin// publish output.Evidence
src/Platform/Microsoft.Testing.Platform.MSBuild/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets:44-47_GenerateTestingPlatformConfigurationFileCoreCondition=" '$(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-72testconfig.jsonnever 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.jsonpresent, then later deletes that file or setsGenerateTestingPlatformConfigurationFile=false, the previously emitted*.testconfig.jsonstays 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 inbin// publish output.Related issues