|
5 | 5 |
|
6 | 6 | using System.Diagnostics;
|
7 | 7 | using System.IO.Pipes;
|
8 |
| -using System.Runtime.InteropServices; |
9 | 8 | using Microsoft.DotNet.Cli.Commands.Test.IPC;
|
10 | 9 | using Microsoft.DotNet.Cli.Commands.Test.IPC.Models;
|
11 | 10 | using Microsoft.DotNet.Cli.Commands.Test.IPC.Serializers;
|
@@ -55,16 +54,6 @@ public async Task<int> RunAsync(TestOptions testOptions)
|
55 | 54 |
|
56 | 55 | private ProcessStartInfo CreateProcessStartInfo(TestOptions testOptions)
|
57 | 56 | {
|
58 |
| - // Check for architecture mismatch when UseAppHost=false |
59 |
| - if (ShouldValidateArchitectureForUseAppHostFalse()) |
60 |
| - { |
61 |
| - var archMismatchError = ValidateArchitectureCompatibility(); |
62 |
| - if (archMismatchError != null) |
63 |
| - { |
64 |
| - throw new GracefulException(archMismatchError); |
65 |
| - } |
66 |
| - } |
67 |
| - |
68 | 57 | var processStartInfo = new ProcessStartInfo
|
69 | 58 | {
|
70 | 59 | // We should get correct RunProperties right away.
|
@@ -379,103 +368,6 @@ public override string ToString()
|
379 | 368 | return builder.ToString();
|
380 | 369 | }
|
381 | 370 |
|
382 |
| - private bool ShouldValidateArchitectureForUseAppHostFalse() |
383 |
| - { |
384 |
| - // Check if UseAppHost=false (RunArguments starts with "exec") |
385 |
| - return !string.IsNullOrEmpty(Module.RunProperties.RunArguments) && |
386 |
| - Module.RunProperties.RunArguments.TrimStart().StartsWith("exec ", StringComparison.OrdinalIgnoreCase); |
387 |
| - } |
388 |
| - |
389 |
| - private string ValidateArchitectureCompatibility() |
390 |
| - { |
391 |
| - // Extract the requested architecture from MSBuild args |
392 |
| - string requestedArch = GetRequestedArchitecture(); |
393 |
| - if (string.IsNullOrEmpty(requestedArch)) |
394 |
| - { |
395 |
| - // No architecture specified, no validation needed |
396 |
| - return null; |
397 |
| - } |
398 |
| - |
399 |
| - // Get current muxer architecture |
400 |
| - string currentArch = GetCurrentMuxerArchitecture(); |
401 |
| - |
402 |
| - // Normalize architecture names for comparison |
403 |
| - string normalizedRequested = NormalizeArchitectureName(requestedArch); |
404 |
| - string normalizedCurrent = NormalizeArchitectureName(currentArch); |
405 |
| - |
406 |
| - if (!string.Equals(normalizedRequested, normalizedCurrent, StringComparison.OrdinalIgnoreCase)) |
407 |
| - { |
408 |
| - return $"The current .NET host does not support the requested target architecture '{requestedArch}'. " + |
409 |
| - $"The current host is running '{currentArch}' architecture. " + |
410 |
| - $"When UseAppHost is false, the target architecture must match the current .NET host architecture."; |
411 |
| - } |
412 |
| - |
413 |
| - return null; |
414 |
| - } |
415 |
| - |
416 |
| - private string GetRequestedArchitecture() |
417 |
| - { |
418 |
| - // Look for architecture in MSBuild args |
419 |
| - foreach (var arg in _buildOptions.MSBuildArgs) |
420 |
| - { |
421 |
| - if (arg.StartsWith("--property:RuntimeIdentifier=", StringComparison.OrdinalIgnoreCase) || |
422 |
| - arg.StartsWith("-property:RuntimeIdentifier=", StringComparison.OrdinalIgnoreCase) || |
423 |
| - arg.StartsWith("/property:RuntimeIdentifier=", StringComparison.OrdinalIgnoreCase) || |
424 |
| - arg.StartsWith("-p:RuntimeIdentifier=", StringComparison.OrdinalIgnoreCase) || |
425 |
| - arg.StartsWith("/p:RuntimeIdentifier=", StringComparison.OrdinalIgnoreCase)) |
426 |
| - { |
427 |
| - var rid = arg.Split('=', 2)[1]; |
428 |
| - return ExtractArchitectureFromRid(rid); |
429 |
| - } |
430 |
| - } |
431 |
| - |
432 |
| - // Also check UnmatchedTokens for --arch parameter |
433 |
| - for (int i = 0; i < _buildOptions.UnmatchedTokens.Count - 1; i++) |
434 |
| - { |
435 |
| - if (_buildOptions.UnmatchedTokens[i] == "--arch" || _buildOptions.UnmatchedTokens[i] == "-a") |
436 |
| - { |
437 |
| - return _buildOptions.UnmatchedTokens[i + 1]; |
438 |
| - } |
439 |
| - } |
440 |
| - |
441 |
| - return null; |
442 |
| - } |
443 |
| - |
444 |
| - private static string ExtractArchitectureFromRid(string rid) |
445 |
| - { |
446 |
| - // RID format is typically os-arch (e.g., linux-x64, win-x86, osx-arm64) |
447 |
| - var parts = rid.Split('-'); |
448 |
| - if (parts.Length >= 2) |
449 |
| - { |
450 |
| - return parts[^1]; // Last part is the architecture |
451 |
| - } |
452 |
| - return rid; // Fallback to the entire string |
453 |
| - } |
454 |
| - |
455 |
| - private static string GetCurrentMuxerArchitecture() |
456 |
| - { |
457 |
| - return RuntimeInformation.ProcessArchitecture switch |
458 |
| - { |
459 |
| - Architecture.X64 => "x64", |
460 |
| - Architecture.X86 => "x86", |
461 |
| - Architecture.Arm => "arm", |
462 |
| - Architecture.Arm64 => "arm64", |
463 |
| - _ => RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant() |
464 |
| - }; |
465 |
| - } |
466 |
| - |
467 |
| - private static string NormalizeArchitectureName(string arch) |
468 |
| - { |
469 |
| - return arch.ToLowerInvariant() switch |
470 |
| - { |
471 |
| - "amd64" => "x64", |
472 |
| - "x86_64" => "x64", |
473 |
| - "arm64" => "arm64", |
474 |
| - "aarch64" => "arm64", |
475 |
| - _ => arch.ToLowerInvariant() |
476 |
| - }; |
477 |
| - } |
478 |
| - |
479 | 371 | public void Dispose()
|
480 | 372 | {
|
481 | 373 | foreach (var namedPipeServer in _testAppPipeConnections)
|
|
0 commit comments