C
C#4w ago
Core

✅ dotnet test: Testing with VSTest target is no longer supported by Microsoft.Testing.Platform

Running dotnet test produces the following error:
c#
Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later. If you use dotnet test, you should opt-in to the new dotnet test experience. For more information, see https://aka.ms/dotnet-test-mtp-error
c#
Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later. If you use dotnet test, you should opt-in to the new dotnet test experience. For more information, see https://aka.ms/dotnet-test-mtp-error
I am using TUnit, and it is constructed on top of Microsoft.Testing.Platform, any idea what might be going on? I checked the link, and gloabl.json includes the necessary config
{
"sdk": {
"allowPrerelease": true
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
{
"sdk": {
"allowPrerelease": true
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
19 Replies
hamarb123
hamarb1234w ago
what version of Microsoft.Testing.Platform does it use?
Core
CoreOP4w ago
v2.0.1
hamarb123
hamarb1234w ago
what error code does it have? - not just the message
Core
CoreOP4w ago
❯ dotnet test Restore complete (1.6s) UaDetector.Abstractions.Tests failed with 1 error(s) (0.0s) /home/nandor/.nuget/packages/microsoft.testing.platform.msbuild/2.0.1/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets(263,5): error Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later. If you use dotnet test, you should opt-in to the new dotnet test experience. For more information, see https://aka.ms/dotnet-test-mtp-error Build failed with 1 error(s) in 2.3s
Testing with 'dotnet test' - .NET
Learn more about how 'dotnet test' works and its support for VSTest and Microsoft.Testing.Platform (MTP)
Core
CoreOP4w ago
This is the output, no error, looks like global.json is not respected
hamarb123
hamarb1234w ago
I assume you have the global.json in the project directory or above, and haven't overridden it with another one closer to the project?
Core
CoreOP4w ago
there is a single global.json at root level, also the sdk "allowPrerelease": true takes effect test config seems to be ignored yes, there's no overriding
hamarb123
hamarb1234w ago
try adding <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> to the test project csproj @Core and then try also adding <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport> maybe if that doesn't work also, ensure the OutputType is Exe I think is what you want for MTP, could be that also, not sure once you get it working, you can remove the unnecessary changes
Core
CoreOP4w ago
This is the csproj
c#
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shouldly" />
<PackageReference Include="TUnit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\UaDetector.Abstractions\UaDetector.Abstractions.csproj" />
</ItemGroup>
</Project>
c#
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shouldly" />
<PackageReference Include="TUnit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\UaDetector.Abstractions\UaDetector.Abstractions.csproj" />
</ItemGroup>
</Project>
hamarb123
hamarb1234w ago
where do you set package version?
Core
CoreOP4w ago
I also tried adding UseMicrosoftTestingPlatformRunner, but same result I'm using central package manager
hamarb123
hamarb1234w ago
are you running dotnet test on the project, or the solution btw?
Core
CoreOP4w ago
It is odd, because tests execute from the IDE, but fail from command line on this specific project
hamarb123
hamarb1234w ago
maybe try solution just in case, but probably won't work
Core
CoreOP4w ago
it doesnt :Smadge:
hamarb123
hamarb1234w ago
try dotnet test --project my.csproj (but with correct file name ofc)
Core
CoreOP4w ago
c#
❯ dotnet test --project tests/UaDetector.Abstractions.Tests.csproj
zsh: correct 'test' to 'tests' [nyae]? n
MSBUILD : error MSB1001: Unknown switch.
Full command line: '/usr/share/dotnet/sdk/10.0.100-rc.1.25451.107/MSBuild.dll -maxcpucount --verbosity:m -tlp:default=auto --property:VsTestUseMSBuildOutput=true --property:NuGetInteractive=true --property:VSTestArtifactsProcessingMode=collect --property:VSTestSessionCorrelationId=15261_36d5d8bb-bbf1-40dd-91a9-89bfce264e13 --restoreProperty:VsTestUseMSBuildOutput=true --restoreProperty:NuGetInteractive=true --restoreProperty:VSTestArtifactsProcessingMode=collect --restoreProperty:VSTestSessionCorrelationId=15261_36d5d8bb-bbf1-40dd-91a9-89bfce264e13 --restoreProperty:EnableDefaultCompileItems=false --restoreProperty:EnableDefaultEmbeddedResourceItems=false --restoreProperty:EnableDefaultNoneItems=false --target:VSTest -nologo --project tests/UaDetector.Abstractions.Tests.csproj -restore'
Switches appended by response files:
Switch: --project
c#
❯ dotnet test --project tests/UaDetector.Abstractions.Tests.csproj
zsh: correct 'test' to 'tests' [nyae]? n
MSBUILD : error MSB1001: Unknown switch.
Full command line: '/usr/share/dotnet/sdk/10.0.100-rc.1.25451.107/MSBuild.dll -maxcpucount --verbosity:m -tlp:default=auto --property:VsTestUseMSBuildOutput=true --property:NuGetInteractive=true --property:VSTestArtifactsProcessingMode=collect --property:VSTestSessionCorrelationId=15261_36d5d8bb-bbf1-40dd-91a9-89bfce264e13 --restoreProperty:VsTestUseMSBuildOutput=true --restoreProperty:NuGetInteractive=true --restoreProperty:VSTestArtifactsProcessingMode=collect --restoreProperty:VSTestSessionCorrelationId=15261_36d5d8bb-bbf1-40dd-91a9-89bfce264e13 --restoreProperty:EnableDefaultCompileItems=false --restoreProperty:EnableDefaultEmbeddedResourceItems=false --restoreProperty:EnableDefaultNoneItems=false --target:VSTest -nologo --project tests/UaDetector.Abstractions.Tests.csproj -restore'
Switches appended by response files:
Switch: --project
hamarb123
hamarb1234w ago
hmm, why is it still using vstest lol have you got the global.json next to the sln or next to the csproj? (try putting it next to the sln, which is hopefully in a dir or 2 above the csproj, if not) anyway, it's late for me so I'm going to go to bed - hope you can get it working 🙂
Core
CoreOP4w ago
Alright, thanks for the help Problem solved, I had to update .net 10 rc1 to rc2

Did you find this page helpful?