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
How do you run x64 .NET Framework tests with Microsoft.Testing.Platform.MSBuild? #2562
Comments
How do you repro that? I am running
In all 3 cases the process is 64-bit. The dll is being compiled as anyCPU (64-bit preferred) with the project below: <!-- file mstest113.csproj -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<EnableMSTestRunner>true</EnableMSTestRunner>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest" Version="3.2.0" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.10.1" />
</ItemGroup>
<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
</Project>
// file MSTestSettings.cs
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] // file UnitTest1.cs
namespace mstest113;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
System.Threading.Thread.Sleep(10_000);
}
} |
I think that could also be related to this xunit/visualstudio.xunit#403 (comment)? |
My binaries are marked properly:
Yet the resulting binary is run as x86:
|
If I simply run the binary directly, you can see it runs in x64 mode:
|
Actually, looking at the log, it may be running in x64 and the output from
(As an aside, what's up with the garbage characters in the log?) |
Can verify that the actual x86 binary is run in 32-bit mode:
|
This is what we do inside the msbuild target <PropertyGroup>
<_TestArchitecture>$(PlatformTarget)</_TestArchitecture>
<_TestArchitecture Condition="'$(PlatformTarget)' == '' or '$(PlatformTarget)' == 'AnyCpu'">x64</_TestArchitecture>
<TestingPlatformShowTestsFailure Condition=" '$(TestingPlatformShowTestsFailure)' == '' ">False</TestingPlatformShowTestsFailure>
<TestingPlatformCaptureOutput Condition=" '$(TestingPlatformCaptureOutput)' == '' " >True</TestingPlatformCaptureOutput>
</PropertyGroup>
<Target Name="InvokeTestingPlatform" >
<InvokeTestingPlatformTask TargetPath="$(TargetPath)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
TargetFramework="$(TargetFramework)"
TestArchitecture="$(_TestArchitecture)"
TestingPlatformShowTestsFailure="$(TestingPlatformShowTestsFailure)"
TestingPlatformCommandLineArguments="$(TestingPlatformCommandLineArguments)"
TestingPlatformCaptureOutput="$(TestingPlatformCaptureOutput)"
DotnetHostPath="$(DOTNET_HOST_PATH)" />
</Target> I saw the same issue and looks like arcade is solving with this default too Can run under binlog? |
@MarcoRossignoli Also, this feels odd:
I will set <!-- ============= -->
<!-- 32-bit builds -->
<PropertyGroup Condition="$(Configuration.EndsWith('_x86'))">
<AssemblyName>$(AssemblyName).x86</AssemblyName>
<DefineConstants>$(DefineConstants);BUILD_X86</DefineConstants>
<PlatformTarget>x86</PlatformTarget>
<RunCommand Condition=" '$(OS)' == 'Windows_NT' ">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
</PropertyGroup> Otherwise, there's no mention of |
@MarcoRossignoli I just went down a rabbit hole just trying to set That said... After I hacked it together (😁) to at least prove it does the right thing, I get the right output: I guess now I'm off to make extra projects, since I appear to have violated some |
Annoying but done. 😭😂 xunit/xunit@4e1033d |
It appears that
dotnet test
with the new testing platform runs .NET Framework tests compiled as AnyCPU as x86 rather than x64 by default.How can I choose the bitness of the test execution engine for .NET Framework tests via
dotnet test
with the new testing platform when the assembly is AnyCPU?The text was updated successfully, but these errors were encountered: