Skip to content

[MTP][Breaking] Don't set IsTestingPlatformApplication at all by MTP #7665

Open

Description

We should consider #7566 as a breaking change.

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.

Activity

  1. added
    type/breaking-change
    area/mtp
    on Apr 2, 2026
  2. MihuBot commented on Apr 2, 2026

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  3. bradwilson commented on Apr 27, 2026

    @bradwilson

    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.

  4. added a commit that references this issue on May 1, 2026
  5. Evangelink commented on Nov 6, 2026

    @Evangelink
    Member

    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?

  6. bradwilson commented on Nov 6, 2026

    @bradwilson

    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?

  7. Evangelink commented on Nov 6, 2026

    @Evangelink
    Member

    I assume you're asking now because your release is coming soon?

    I would like to release toward end of November but I want to have clear impact and ideally alignment with framework authors.

  8. bradwilson commented on Nov 6, 2026

    @bradwilson

    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.

  9. Evangelink commented on Nov 27, 2026

    @Evangelink
    Member

    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.Platform package sets IsTestingPlatformApplication in buildTransitive meaning 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 IsTestingPlatformApplication based on EnableMSTestRunner also in buildTransitive.

    As far as I see, we have 2 main options:

    1. 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).

    2. We remove setting property from MTP buildTransitive and you have to start setting it on your adapter packages.

    I am also all hears if you have other suggestions

  10. thomhurst commented on Nov 27, 2026

    @thomhurst
    Contributor

    We remove setting property from MTP buildTransitive and you have to start setting it on your adapter packages.

    Won't we just have to do the above though?
    Is 1. actually causing any problems?

  11. Evangelink commented on Nov 27, 2026

    @Evangelink
    Member

    Won't we just have to do the above though?

    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:

    image

    if you set <IsTestingPlatformApplication>false</...> on the helper then it's shown as exe:

    image
  12. 2 remaining items

  13. thomhurst commented on Nov 27, 2026

    @thomhurst
    Contributor

    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?

  14. bradwilson commented on Nov 27, 2026

    @bradwilson

    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.

  15. OsirisTerje commented on Nov 27, 2026

    @OsirisTerje

    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.

  16. bradwilson commented on Nov 27, 2026

    @bradwilson

    My point is : if a user explicitly sets IsTestingPlatformApplication, the adapter shouldn’t silently overwrite it

    xUnit.net will not overwrite, only set to true if it's not set.

  17. bradwilson commented on Nov 27, 2026

    @bradwilson

    I haven't validated this

    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. 😆)

  18. bradwilson commented on Nov 27, 2026

    @bradwilson

    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.
    
  19. bradwilson commented on Nov 27, 2026

    @bradwilson

    Currently pulling 3.0.0-preview.26577.6 from https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json

  20. Evangelink commented on Nov 28, 2026

    @Evangelink
    Member

    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...

  21. bradwilson commented on Nov 28, 2026

    @bradwilson

    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...

  22. thomhurst commented on Nov 28, 2026

    @thomhurst
    Contributor

    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

  23. bradwilson commented on Nov 28, 2026

    @bradwilson

    are you using net8 or 9?

    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.

  24. bradwilson commented on Nov 28, 2026

    @bradwilson

    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)

  25. thomhurst commented on Nov 28, 2026

    @thomhurst
    Contributor

    It'd make sense as they're EOL since November 10th: https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core

  26. bradwilson commented on Nov 28, 2026

    @bradwilson

    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.

  27. bradwilson commented on Nov 28, 2026

    @bradwilson

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mtptype/breaking-change

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions