dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

macOS: Support selecting dotnet architecture or path for launch configuration #4851

Closed cwensley closed 3 years ago

cwensley commented 3 years ago

Issue Description

With the advent of .NET 6 RC2 on Apple Silicon (or Windows ARM64), it now installs the arm64 version in /usr/local/share/dotnet, and the x64 version in /usr/local/share/dotnet/x64. It was announced here.

The problem is that the arm64 build is unable to debug an x64 app and vice versa. The only way to support debugging an x64 app is to set the dotnet path globally to use the x64 version.

The launch configuration should be able to specify which dotnet to use when debugging, depending on the app you are launching.

The guidance above says to set the path to switch between them, but adding this to the launch config does not seem to work:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch My x64 App",
            "type": "coreclr",
            "request": "launch",
            "program": "/Path/ToMyApp",
            "environment": [
                { "name": "PATH", "value": "/usr/local/share/dotnet/x64:${env:PATH}" }
            ]
        },

Steps to Reproduce

Launch an x64 app for debugging on an Apple Silicon Mac.

Expected Behavior

Should debug properly.

Actual Behavior

Unable to attach to CoreCLR. Unknown Error: 0x80131c3c

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.61.2 C# Extension: 1.23.16

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.100-rc.2.21505.57 Commit: ab39070116 Runtime Environment: OS Name: Mac OS X OS Version: 11.6 OS Platform: Darwin RID: osx.11.0-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.100-rc.2.21505.57/ Host (useful for support): Version: 6.0.0-rc.2.21480.5 Commit: 6b11d64e7e .NET SDKs installed: 6.0.100-rc.2.21505.57 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |binary-plist|dnicolson|0.7.0| |cpptools|ms-vscode|1.7.1| |csharp|ms-dotnettools|1.23.16| |csharpextensions|jchannon|1.3.1| |csharpextensions|kreativ-software|1.5.2| |docomment|k--kato|0.1.20| |dotnet|leo-labs|1.3.0| |dotnet-test-explorer|formulahendry|0.7.7| |EditorConfig|EditorConfig|0.16.4| |eml|leighlondon|0.4.0| |gitlens|eamodio|11.6.1| |jupyter-renderers|ms-toolsai|1.0.3| |lunatic-file-picker|DmitriyMuraviov|0.1.2| |macros|geddski|1.2.1| |mono-debug|ms-vscode|0.16.2| |msbuild-project-tools|tintoy|0.3.15| |openvpn|idleberg|0.2.3| |powershell|ms-vscode|2021.10.1| |propertylist|zhouronghui|0.0.2| |python|ms-python|2021.10.1365161279| |rhino-debug|mcneel|0.3.0| |shader|slevesque|1.1.5| |syntax-project-pbxproj|mariomatheu|0.1.3| |t4-support|zbecknell|0.5.0| |tasks-shell-input|augustocdias|1.6.0| |test-adapter-converter|ms-vscode|0.1.4| |vscode-clangd|llvm-vs-code-extensions|0.1.13| |vscode-commons|redhat|0.0.6| |vscode-dotnet-runtime|ms-dotnettools|1.3.0| |vscode-eslint|dbaeumer|2.2.2| |vscode-nuget-package-manager|jmrog|1.1.6| |vscode-open-in-github|fabiospampinato|1.3.0| |vscode-pylance|ms-python|2021.10.3| |vscode-solution-explorer|fernandoescolar|0.4.4| |vscode-yaml|redhat|1.1.0| |xml|DotJoshJohnson|2.5.1|;
gregg-miskelly commented 3 years ago

@cwensley You need to add "targetArchitecture": "x86_64" to your launch.json configuration.

cwensley commented 3 years ago

🤦🏻‍♂️ whoops, I missed that setting! Thanks for the response, it looks like it works perfectly.