I don't have VS 2017, and I'll be building a web front-end in VS Code anyway so I want to use VS Code.
Until .NET Standard 2.0 comes out, our libraries are also in 4.6.1, so I'm targetting net461 in my .NET Core csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
</ItemGroup>
</Project>
The project is the simplest dotnet new webapi
starter app. I can build and run with dotnet build
and dotnet run
. I've also got the latest ms-vscode.csharp extension 1.8.1.
However, when I try attaching or debugging this application with VS Code I get the error
Failed to attach to process: Only 64-bit processes can be debugged
Even running from console, then attaching with the very simple configuration:
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
And selecting the process fails with this error. I've tried building the exe targeting x64 with:
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Platform>x64</Platform>
</PropertyGroup>
But it produces the same error. Anyone know a fix? It seems to be because I'm targetting net461, does debugging .Net Core not support targeting other frameworks?
Version 1.9.0 of the ms-vscode.csharp extension added desktop CLR support.
Modify your launch.json file:
"type" : "clr",
"program" : "path to x64 version of the executable.exe"
To target x64, modify your .csproj file like so:
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
An example program path after specifying the runtime id:
"program" : ${workspaceRoot}/src/bin/Debug/net461/win7-x64/example.exe