Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSTest.Sdk 3.7.0 issues when targeting .NET Framework 4.8 #4426

Open
avivanoff opened this issue Dec 22, 2024 · 8 comments
Open

MSTest.Sdk 3.7.0 issues when targeting .NET Framework 4.8 #4426

avivanoff opened this issue Dec 22, 2024 · 8 comments

Comments

@avivanoff
Copy link

When using MSTest.Sdk 3.7.0 in the test project targeting .NET Framework 4.8 I found the following issues:

  • No DLL is produced, only EXE.
  • Executing tests from Visual Studio fails with:
    An exception occurred while test discoverer 'MSTestDiscoverer' was loading tests. Exception: Could not load file or assembly 'Microsoft.Testing.Platform, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

When projects target .NET 8 the aforementioned issues are not present. See the sample project.

@Youssef1313
Copy link
Member

I'm unable to reproduce

Image

@Youssef1313
Copy link
Member

I can only reproduce this when the server mode option in Visual Studio is not enabled.

Can you please make sure the option is enabled?

Image

@avivanoff
Copy link
Author

@Youssef1313, what about DLL? Why is it not being built? And why do .NET 8 and .NET 4.8 behaviors are different?

@Evangelink
Copy link
Member

@avivanoff this is the normal behavior of runtime when building an exe for net framework VS netcore/net.

@BoBoBaSs84
Copy link

BoBoBaSs84 commented Dec 23, 2024

I can confirm this, but with 4.62 & 4.72 ..

The build does not show any issues.

Image

Running the tests via test explorer shows only not run.

Image

The test output exposes some issues.

Image

The pipeline on the other hand does not show any issues. (ubuntu-latest)

Image

Edit says:

Image

Edit says again:

Turning server mode to on and restarting VS did not resolve the problem.

Image

@factorysoft-01
Copy link

Using project file like <Project Sdk="MSTest.Sdk/3.7.0"> and <TargetFramework>net48</TargetFramework> fix the problem.

Using project file like <Project Sdk="Microsoft.NET.Sdk"> and <TargetFramework>net48</TargetFramework> and <PackageReference Include="MSTest" Version="3.7.0" /> VS Test Explorer will not run tests.

Using project file like <Project Sdk="Microsoft.NET.Sdk"> and <TargetFramework>net48</TargetFramework> and <PackageReference Include="MSTest" Version="3.7.0" /> tests always run on build server with build tools 2022.

@BoBoBaSs84
Copy link

BoBoBaSs84 commented Dec 25, 2024

@factorysoft-01 Nope, that does not work either.

I changed the project file:

Image

I then ran the tests in the test explorer, with the same result:

Image

The test output gave me the same errors as before:

No test is available in D:\Source\BB84.Extensions\src\BB84.Extensions\bin\Debug\net462\BB84.Extensions.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. An exception occurred while test discoverer 'MSTestDiscoverer' was loading tests. Exception: Could not load file or assembly 'Microsoft.Testing.Platform, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. No test is available in D:\Source\BB84.Extensions\tests\BB84.ExtensionsTests\bin\Debug\net462\BB84.ExtensionsTests.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

If I run the tests via the cli, the error does not occur:

Image

Edit says:

When running along with <Project Sdk="MSTest.Sdk/3.6.4"> it works like a charm:

Image

@factorysoft-01
Copy link

factorysoft-01 commented Dec 25, 2024

MSNetSdk.zip

I change the sample from @avivanoff to MSNetSDK and Package Reference v3.7.0. The test never run with VS Explorer 2022 v17.12.3.

The original sample work for me.

Hope this helps.

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

No branches or pull requests

5 participants