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

Unsupported Platform target x86 in version 17.7.0? #4650

Closed
norigeist opened this issue Aug 9, 2023 · 11 comments
Closed

Unsupported Platform target x86 in version 17.7.0? #4650

norigeist opened this issue Aug 9, 2023 · 11 comments

Comments

@norigeist
Copy link

Description

I have an issue where my unit tests are not executed on upgrading Micosoft.NET.Test.Sdk from version 17.6.3 to 17.7.0. My test project has the Platform target set to x86.

The tests are shown in Visual Studio 2022 - Test Explorer, but they are not running on execution.

Steps to reproduce

The issue is reproducible by creating a new test project (xUnit or MSTest Test Project) in Visual Studio 2022. From there...

Working version

  1. Update the NuGet package of Micosoft.NET.Test.Sdk to 17.6.3
  2. Set the Platform target of the test Project to x86
  3. Add a simple unit test
  4. Execute the test
  5. ✅ Passed

Not working version

  1. Update the NuGet package of Micosoft.NET.Test.Sdk to 17.7.0
  2. Execute the test
  3. ❔ Nothing happens

Expected behavior

The same behavior as in version 17.6.3 that the tests are executed.

Actual behavior

The unit tests are not executed. The logs say that they were not discovered...

Diagnostic logs

Executed from MSTest Test Project

No test is available in C:\Users\Developer\Documents\Projects\repository\Project.MSTest.Tests\bin\Debug\net6.0\Project.MSTest.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.

Executed from xUnit

[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.5+1caef2f33e (64-bit .NET 7.0.10)
[xUnit.net 00:00:01.20] Skipping: Project.xUnit.Tests (could not find dependent assembly 'Project.xUnit.Tests, Version=0.0.0')
No test is available in C:\Users\Developer\Documents\Projects\repository\Project.xUnit.Tests\bin\Debug\net7.0\Project.xUnit.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Environment

OS: Windows 10 Version 22H2 (Build 19045.3271)
IDE: Visual Studio 2022 17.6.5
Installed .NET SDKs: .NET 6, 7
vstest.console.dll, Version: 17.6.3-release-20230616-01

@nohwnd
Copy link
Member

nohwnd commented Aug 10, 2023

Can you really reproduce this with xunit? Because I can't

image

@nohwnd
Copy link
Member

nohwnd commented Aug 10, 2023

vstest.console S:\t\mstest77\bin\x86\Debug\net7.0\mstest77.dll --diag:logs
Microsoft (R) Test Execution Command Line Tool Version 17.6.2-release-20230615-01 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait...
Logging Vstest Diagnostics in file: S:\t\mstest77\logs\vstest.console_57264.diag
A total of 1 test files matched the specified pattern.
[MSTest][Discovery][S:\t\mstest77\bin\x86\Debug\net7.0\mstest77.dll] Failed to discover tests from assembly S:\t\mstest77\bin\x86\Debug\net7.0\mstest77.dll. Reason:Could not load file or assembly 'mstest77, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
No test is available in S:\t\mstest77\bin\x86\Debug\net7.0\mstest77.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:.

@nohwnd nohwnd pinned this issue Aug 10, 2023
@smkanadl
Copy link

I am having this issue in CI builds, using the MS hosted agents.

It's a multi-targeted NUnit project that also targets netcoreapp3.1.

I have installed the netcoreapp3.1 runtime in x86 using the dotnet-install script and run the test using

dotnet test Project -- RunConfiguration.TargetPlatform=x86

I end up with a You must install or update .NET to run this application error message. Same for x64 works fine.

@nohwnd
Copy link
Member

nohwnd commented Aug 11, 2023

@smkanadl are you hitting this with just 17.7.0 or 17.6.3 as well? Because needing x86 runtime is a normal behavior of a .NET application that is built via any SDK (no matter if x64, x86 or arm64), and x86 runtime is not installed by default IIRC. You can check "C:\Program Files (x86)\dotnet\dotnet.exe" --info, and see if you have the runtime listed in your list of x86 runtimes.

@smkanadl
Copy link

@nohwnd I am hitting this with 17.7.0 only. My pipeline was working fine with 17.6.1 before. When I upgraded to 17.7.0 it stopped working. Going back to 17.6.3 fix the problems.

The matching x86 runtime was always installed. I also tried to install the full x86 SDK to get 17.7.0 working, but that didn't help either.

@nohwnd
Copy link
Member

nohwnd commented Aug 11, 2023

Thanks for the info, will try it.

@nohwnd
Copy link
Member

nohwnd commented Aug 11, 2023

I don't see it, do you have more output in that console?

How I do it:

dotnet test -- RunConfiguration.TargetPlatform=x86
  Determining projects to restore...
  All projects are up-to-date for restore.
  mstest78 -> S:\t\mstest78\bin\Debug\net7.0\mstest78.dll
Test run for S:\t\mstest78\bin\Debug\net7.0\mstest78.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.7.0-preview-23364-03+bc17bb9693cfc4778ded51aa0ab7f1065433f989 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 15 ms - mstest78.dll (net7.0)
<!-- file mstest78.csproj -->
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
    <PackageReference Include="coverlet.collector" Version="3.2.0" />
  </ItemGroup>

</Project>
S:\t\mstest78> dotnet --version
7.0.400

@norigeist
Copy link
Author

Can you really reproduce this with xunit? Because I can't

Yes, I can still reproduce with an xUnit project.

I don't see it, do you have more output in that console?

<!-- file mstest78.csproj -->
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
    <PackageReference Include="coverlet.collector" Version="3.2.0" />
  </ItemGroup>

</Project>

As far as I can see, <PlatformTarget>x86</PlatformTarget> is missing in the .csproj to reproduce the behaviour.

@nohwnd
Copy link
Member

nohwnd commented Aug 11, 2023

Found it. We have been doing full rewrite of how we package the app in 17.7.0 to build via the common build system Arcade, and the testhost we shipped in testhost.x86 is running as x64. I can see it fail in the same callstack when loading the dll into a plain x64 .net 7 console app. Surprisingly this error message is not mentioning anything about wrong image format, which is unexpected to me.

dumpbin /headers S:\t\xunit13\bin\Debug\net7.0\testhost.x86.exe
Microsoft (R) COFF/PE Dumper Version 14.38.32919.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file S:\t\xunit13\bin\Debug\net7.0\testhost.x86.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
            8664 machine (x64)
               7 number of sections
        63747414 time date stamp Wed Nov 16 06:24:36 2022
               0 file pointer to symbol table
               0 number of symbols
              F0 size of optional header
              22 characteristics
                   Executable
                   Application can handle large (>2GB) addresses

@nohwnd
Copy link
Member

nohwnd commented Aug 11, 2023

Fixes are building, if tests pass I will backport to 17.7.x and we should release patch on Tuesday.

@nohwnd
Copy link
Member

nohwnd commented Aug 16, 2023

Fixed in 17.7.1 that is now released and we will be inserting into net7 and next servicing of VS.

cc @cvpoienaru

@nohwnd nohwnd closed this as completed Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants