You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MTP][Breaking] Don't set IsTestingPlatformApplication at all by MTP #7665
One additional benefit here is, because MTP itself won't set a default, test frameworks will have the ability to not touch the property at all if it has a value, which means it's user specified value. This is a problem today for at NUnit/MSTest because we always overwrite IsTestingPlatformApplication, and only letting EnableNUnitRunner and EnableMSTestRunner control it. So users cannot set it in csproj at all which was causing confusion.
I think failing to take into account the discussion in #7566, especially #7566 (comment), you're turning what should be a small impact breaking change into a huge impact one.
Brad Wilson (@bradwilson) we are considering doing this change for MTP v3. I have followed discussion on the initial PR and I saw you did some changes, is this soemthing fine for you?
Assuming you haven't changed your mind about putting the property into MTP.MSBuild, there's nothing I can do to fix people using versions of xUnit.net v3 prior to 4.0.0 against MTP v3. They will be silently broken.
Our strategy with your major versions has been to ship new packages with new version names (meaning we would add .mtp-v3 packages), so people aren't arbitrarily surprised by any dependencies they need that may not have been updated and may now be broken. I don't see any reason not to continue to use this strategy, and then bump up our default from MTP v2 to v3 with our next major release (currently unplanned).
I assume you're asking now because your release is coming soon?
I generally do a release about once a month, and I will be doing one this weekend, which will put the next release in early December. I can add an .mtp-v3 package at that time.
For MSTest, this is not a problem because we change IsTestingPlatformApplication based on EnableMSTestRunner also in buildTransitive.
As far as I see, we have 2 main options:
We keep current behavior, assuming it's uncommon scenario for an executable to reference an executable and we document this case and what people have to do (e.g. set PrivateAssets="all" or IsTestingApplication to false).
We remove setting property from MTP buildTransitive and you have to start setting it on your adapter packages.
No because it would be on build not on buildTransitive so it stop at the first "thing" referencing the package (most of the time the test app).
Is 1. actually causing any problems?
In current state, the test app (XXX.Helper) is considered a test app so doing dotnet test would fail saying it didn't contain tests + VS shows the app as test app:
if you set <IsTestingPlatformApplication>false</...> on the helper then it's shown as exe:
We keep current behavior, assuming it's uncommon scenario for an executable to reference an executable and we document this case and what people have to do
We actually explicitly do not support this. We have two (base) packages: xunit.v3.core.mtp-v2 is used by unit test projects, and xunit.v3.extensibility.core which can be used by anything providing extensibility. We would expect people to use the latter for a "unit test support library".
We only include Microsoft.Testing.Platform in the former case. Our extensibility package does not have any MTP package references, because we need those things for the in-process runner, not for the core framework. (We also include Microsoft.Testing.Extensions.Telemetry, Microsoft.Testing.Extensions.Telemetry, and Microsoft.Testing.Platform.MSBuild for xunit.v3.core.mtp-v2.)
Additionally, we don't explicitly support people upgrading major versions of MTP (if it works, it works, but we're not going to support any issues that come from it), which is why we will ship .mtp-v3 variants once it reaches RTW.
The NUnit adapter sets this today
We are also setting this now as of 4.0.0 in our buildTransitive .props file for xunit.v3.core.mtp-v2 (and this would include .mtp-v3). This means people could use any 4.0.0+ version with MTP v3, assuming there are no breaking changes in our/their usage. I haven't validated this, since it's not supported.
Xxx.Helpers should probably be a library, not an executable, to avoid something like this?
That is our recommendation, and we've aligned our packages to make this scenario possible.
It's a bit tricky that's why I prefer to have a consensus here. Basically I think the current design is more correct
My point is : if a user explicitly sets IsTestingPlatformApplication, the adapter shouldn’t silently overwrite it. The better pattern is not to remove all defaults, but to provide a default only when the user has not set the property. For NUnit, that default can still come from EnableNUnitRunner. Which is why I said this is a more correct way.
The key distinction is that the reported leak comes from MTP setting the property in buildTransitive, while our adapter targets are packaged under build. So MTP should stop setting a universal transitive value, and each framework package should set its own default in build, but preserving an explicit user value.
The case of a non-test executable referencing a test project may be uncommon, but I have seen it used (non-MTP). In such cases MTP’s transitive default can cause the helper executable to be treated as a test app. Users need a reliable way to set IsTestingPlatformApplication to false and have that explicit setting respected. Framework defaults are useful, but they should not override a project-level choice.
I set up a local branch to test MTP v3, and found no breaking changes in my test suite. (The dependency on System.Memory is newer than we take, which is only minorly annoying. 😆)
Actually, I spoke too soon. Native AOT is broken right now:
/_/src/MTP/Microsoft.Testing.Platform/Builder/TestApplication.cs(196): error IL3000: Microsoft.Testing.Platform.Builder.TestApplication.<LogInformationAsync>d__7.MoveNext(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
/_/src/MTP/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs(79): error IL3000: Microsoft.Testing.Platform.Services.CurrentTestApplicationModuleInfo.TryGetCurrentTestApplicationFullPath(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
C:\Users\bradwilson\.nuget\packages\microsoft.applicationinsights\2.23.0\lib\netstandard2.0\Microsoft.ApplicationInsights.dll : error IL2104: Assembly 'Microsoft.ApplicationInsights' produced trim warnings. For more information see https://aka.ms/il2104
C:\Users\bradwilson\.nuget\packages\microsoft.applicationinsights\2.23.0\lib\netstandard2.0\Microsoft.ApplicationInsights.dll : error IL3053: Assembly 'Microsoft.ApplicationInsights' produced AOT analysis warnings.
C:\Users\bradwilson\.nuget\packages\microsoft.testing.platform\3.0.0-preview.26577.6\lib\netstandard2.0\Microsoft.Testing.Platform.dll : error IL2104: Assembly 'Microsoft.Testing.Platform' produced trim warnings. For more information see https://aka.ms/il2104
/_/src/MTP/Microsoft.Testing.Platform/CommandLine/CommandLineHandler.cs(124): error IL3000: Microsoft.Testing.Platform.CommandLine.CommandLineHandler.<>c__DisplayClass29_0.<<PrintInfoAsync>g__DisplayPlatformInfoAsync|0>d.MoveNext(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
C:\Users\bradwilson\.nuget\packages\microsoft.dotnet.ilcompiler\9.0.23\build\Microsoft.NETCore.Native.targets(317,5): error MSB3077: The command ""C:\Users\bradwilson\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\9.0.23\tools\\ilc" @"obj\Release\net9.0\win-x64\native\xunit.v3.assert.aot.tests.ilc.rsp"" exited with return value 0, but errors were detected during execution. ExitCode was set to -1.
Actually, I spoke too soon. Native AOT is broken right now:
/_/src/MTP/Microsoft.Testing.Platform/Builder/TestApplication.cs(196): error IL3000: Microsoft.Testing.Platform.Builder.TestApplication.<LogInformationAsync>d__7.MoveNext(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
/_/src/MTP/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs(79): error IL3000: Microsoft.Testing.Platform.Services.CurrentTestApplicationModuleInfo.TryGetCurrentTestApplicationFullPath(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
C:\Users\bradwilson\.nuget\packages\microsoft.applicationinsights\2.23.0\lib\netstandard2.0\Microsoft.ApplicationInsights.dll : error IL2104: Assembly 'Microsoft.ApplicationInsights' produced trim warnings. For more information see https://aka.ms/il2104
C:\Users\bradwilson\.nuget\packages\microsoft.applicationinsights\2.23.0\lib\netstandard2.0\Microsoft.ApplicationInsights.dll : error IL3053: Assembly 'Microsoft.ApplicationInsights' produced AOT analysis warnings.
C:\Users\bradwilson\.nuget\packages\microsoft.testing.platform\3.0.0-preview.26577.6\lib\netstandard2.0\Microsoft.Testing.Platform.dll : error IL2104: Assembly 'Microsoft.Testing.Platform' produced trim warnings. For more information see https://aka.ms/il2104
/_/src/MTP/Microsoft.Testing.Platform/CommandLine/CommandLineHandler.cs(124): error IL3000: Microsoft.Testing.Platform.CommandLine.CommandLineHandler.<>c__DisplayClass29_0.<<PrintInfoAsync>g__DisplayPlatformInfoAsync|0>d.MoveNext(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
C:\Users\bradwilson\.nuget\packages\microsoft.dotnet.ilcompiler\9.0.23\build\Microsoft.NETCore.Native.targets(317,5): error MSB3077: The command ""C:\Users\bradwilson\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\9.0.23\tools\\ilc" @"obj\Release\net9.0\win-x64\native\xunit.v3.assert.aot.tests.ilc.rsp"" exited with return value 0, but errors were detected during execution. ExitCode was set to -1.
WoW, I guess now I need to work out why our tests are not catching that...
Brad Wilson (@bradwilson) are you using net8 or 9? You're getting the netstandard2.0 binaries. Looks like MTP v3 is netstandard, 10 or 11, so 8 and 9 will fallback to netstandard which don't work well with AOT afaik
Good catch, that's what it is. Our minimum for AOT is net9.0. Bumping this to net10.0 would of course make me want to have a major version rev, so maybe we can't support MTP v3 right now.
Hmm, maybe we could say the MTP v3 packages don't support net8.0 or net9.0. Is the limitation just for Native AOT? I assume the non-AOT netstandard2.0 packages should be fine on net8.0 and net9.0. What about support? Is the team declaring that net8.0 and net9.0 are officially unsupported for MTP v3? Amaury Levé (@Evangelink)
I know they're EOL, but that doesn't mean people will stop using them immediately. Based on some polling I did there's going to be a LOT of people still on .NET 8 for at least the next 6-12 months.
Clearly, at least with the build I'm using right now, net8.0 non-AOT is working just fine for MTP v3. If they're really trying to ship this in the next few days, I doubt they're going to introduce any new breaking changes. But if the team's stance is a hard "no net8.0 or net9.0" then I will take the same line for the non-AOT MTP v3 packages (and I don't have a choice for AOT). It'll just be part of the release notes.
Activity
MihuBot commentedon Apr 2, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
bradwilson commentedon Apr 27, 2026
I think failing to take into account the discussion in #7566, especially #7566 (comment), you're turning what should be a small impact breaking change into a huge impact one.
microsoft/testfx#7665: Set IsTestingPlatformApplication
Evangelink commentedon Nov 6, 2026
Brad Wilson (@bradwilson) we are considering doing this change for MTP v3. I have followed discussion on the initial PR and I saw you did some changes, is this soemthing fine for you?
bradwilson commentedon Nov 6, 2026
Assuming you haven't changed your mind about putting the property into MTP.MSBuild, there's nothing I can do to fix people using versions of xUnit.net v3 prior to 4.0.0 against MTP v3. They will be silently broken.
Our strategy with your major versions has been to ship new packages with new version names (meaning we would add
.mtp-v3packages), so people aren't arbitrarily surprised by any dependencies they need that may not have been updated and may now be broken. I don't see any reason not to continue to use this strategy, and then bump up our default from MTP v2 to v3 with our next major release (currently unplanned).I assume you're asking now because your release is coming soon?
Evangelink commentedon Nov 6, 2026
I would like to release toward end of November but I want to have clear impact and ideally alignment with framework authors.
bradwilson commentedon Nov 6, 2026
I generally do a release about once a month, and I will be doing one this weekend, which will put the next release in early December. I can add an
.mtp-v3package at that time.Evangelink commentedon Nov 27, 2026
Brad Wilson (@bradwilson) Tom Longhurst (@thomhurst) Terje Sandstrom (@OsirisTerje) I have investigated the original issue that lead Youssef to create this ticket and to simplify the discussion I have created a repro for all the test frameworks in MTPFrameworkReferences.zip.
The gist of the issue is that
Microsoft.Testing.Platformpackage setsIsTestingPlatformApplicationinbuildTransitivemeaning that test frameworks don't have to set it but also that any project referencing a test project gets it also (see https://github.com/microsoft/testfx/blob/main/src/MTP/Microsoft.Testing.Platform/buildMultiTargeting/Microsoft.Testing.Platform.targets).For MSTest, this is not a problem because we change
IsTestingPlatformApplicationbased onEnableMSTestRunneralso inbuildTransitive.As far as I see, we have 2 main options:
We keep current behavior, assuming it's uncommon scenario for an executable to reference an executable and we document this case and what people have to do (e.g. set
PrivateAssets="all"orIsTestingApplicationtofalse).We remove setting property from MTP
buildTransitiveand you have to start setting it on your adapter packages.I am also all hears if you have other suggestions
thomhurst commentedon Nov 27, 2026
Won't we just have to do the above though?
Is 1. actually causing any problems?
Evangelink commentedon Nov 27, 2026
No because it would be on
buildnot onbuildTransitiveso it stop at the first "thing" referencing the package (most of the time the test app).In current state, the test app (XXX.Helper) is considered a test app so doing
dotnet testwould fail saying it didn't contain tests + VS shows the app as test app:if you set
<IsTestingPlatformApplication>false</...>on the helper then it's shown as exe:2 remaining items
thomhurst commentedon Nov 27, 2026
Xxx.Helpers should probably be a library, not an executable, to avoid something like this?
That being said, I don't mind making this change if we need to though. Is there any other breaking changes to bundle in though or is this all for now?
bradwilson commentedon Nov 27, 2026
We actually explicitly do not support this. We have two (base) packages:
xunit.v3.core.mtp-v2is used by unit test projects, andxunit.v3.extensibility.corewhich can be used by anything providing extensibility. We would expect people to use the latter for a "unit test support library".We only include
Microsoft.Testing.Platformin the former case. Our extensibility package does not have any MTP package references, because we need those things for the in-process runner, not for the core framework. (We also includeMicrosoft.Testing.Extensions.Telemetry,Microsoft.Testing.Extensions.Telemetry, andMicrosoft.Testing.Platform.MSBuildforxunit.v3.core.mtp-v2.)Additionally, we don't explicitly support people upgrading major versions of MTP (if it works, it works, but we're not going to support any issues that come from it), which is why we will ship
.mtp-v3variants once it reaches RTW.We are also setting this now as of 4.0.0 in our buildTransitive
.propsfile forxunit.v3.core.mtp-v2(and this would include.mtp-v3). This means people could use any 4.0.0+ version with MTP v3, assuming there are no breaking changes in our/their usage. I haven't validated this, since it's not supported.That is our recommendation, and we've aligned our packages to make this scenario possible.
OsirisTerje commentedon Nov 27, 2026
My point is : if a user explicitly sets IsTestingPlatformApplication, the adapter shouldn’t silently overwrite it. The better pattern is not to remove all defaults, but to provide a default only when the user has not set the property. For NUnit, that default can still come from EnableNUnitRunner. Which is why I said this is a more correct way.
The key distinction is that the reported leak comes from MTP setting the property in buildTransitive, while our adapter targets are packaged under build. So MTP should stop setting a universal transitive value, and each framework package should set its own default in build, but preserving an explicit user value.
The case of a non-test executable referencing a test project may be uncommon, but I have seen it used (non-MTP). In such cases MTP’s transitive default can cause the helper executable to be treated as a test app. Users need a reliable way to set IsTestingPlatformApplication to false and have that explicit setting respected. Framework defaults are useful, but they should not override a project-level choice.
bradwilson commentedon Nov 27, 2026
xUnit.net will not overwrite, only set to
trueif it's not set.bradwilson commentedon Nov 27, 2026
I set up a local branch to test MTP v3, and found no breaking changes in my test suite. (The dependency on
System.Memoryis newer than we take, which is only minorly annoying. 😆)bradwilson commentedon Nov 27, 2026
Actually, I spoke too soon. Native AOT is broken right now:
bradwilson commentedon Nov 27, 2026
Currently pulling
3.0.0-preview.26577.6fromhttps://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.jsonEvangelink commentedon Nov 28, 2026
WoW, I guess now I need to work out why our tests are not catching that...
bradwilson commentedon Nov 28, 2026
It could be something broken in my build system. It is confusing when I look at your source, this doesn't seem like it should be happening...
thomhurst commentedon Nov 28, 2026
Brad Wilson (@bradwilson) are you using net8 or 9? You're getting the netstandard2.0 binaries. Looks like MTP v3 is netstandard, 10 or 11, so 8 and 9 will fallback to netstandard which don't work well with AOT afaik
bradwilson commentedon Nov 28, 2026
Good catch, that's what it is. Our minimum for AOT is net9.0. Bumping this to net10.0 would of course make me want to have a major version rev, so maybe we can't support MTP v3 right now.
bradwilson commentedon Nov 28, 2026
Hmm, maybe we could say the MTP v3 packages don't support net8.0 or net9.0. Is the limitation just for Native AOT? I assume the non-AOT
netstandard2.0packages should be fine onnet8.0andnet9.0. What about support? Is the team declaring thatnet8.0andnet9.0are officially unsupported for MTP v3? Amaury Levé (@Evangelink)thomhurst commentedon Nov 28, 2026
It'd make sense as they're EOL since November 10th: https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core
bradwilson commentedon Nov 28, 2026
I know they're EOL, but that doesn't mean people will stop using them immediately. Based on some polling I did there's going to be a LOT of people still on .NET 8 for at least the next 6-12 months.
bradwilson commentedon Nov 28, 2026
Clearly, at least with the build I'm using right now, net8.0 non-AOT is working just fine for MTP v3. If they're really trying to ship this in the next few days, I doubt they're going to introduce any new breaking changes. But if the team's stance is a hard "no net8.0 or net9.0" then I will take the same line for the non-AOT MTP v3 packages (and I don't have a choice for AOT). It'll just be part of the release notes.