我目前正在努力将现有的.NET Framework 4.5.2项目与新的ASP.NET Core项目集成。我使用.NET Core SDK 1.1.1构建
到目前为止我所拥有的是一个简单的ASP脚手架,它运行并且能够加载我的旧项目DLL,但是我无法使用VS Code调试它,因为生成的PDB似乎被忽略了。
这是csproj(我删除了对旧项目的包引用,但问题仍然存在)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
当我将TargetFramework更改为netcoreapp1.1时,会创建一个DLL而不是EXE,并且调试工作正常。任何想法为什么?
这是dotnet --info
的输出 .NET Command Line Tools (1.0.1)
Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.1
答案 0 :(得分:2)
更新: C#扩展1.9.0支持.NET Framework调试。见https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.9.0
要执行此操作,请将“type”设置为clr
,并确保您的项目生成便携式PDB。见https://github.com/OmniSharp/omnisharp-vscode/wiki/Portable-PDBs
的csproj
<PropertyGroup>
<DebugType>portable</DebugType>
</PropertyGroup>
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Framework Launch (console)",
"type": "clr",
"request": "launch",
"program": "${workspaceRoot}/bin/Debug/net461/sample.exe",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
<强>原始强>
在.NET Core中,可执行项目会生成“.dll”文件。要启动它,请运行“dotnet.exe ./myapp.dll”。
在.NET Framework中,可执行项目生成“.exe”文件。要启动它,请直接运行该文件:“myapp.exe”。
在撰写本文时(2017年3月),VS Code仅支持调试.NET Core进程。您可以在此处跟踪要调试.NET Framework的功能请求:https://github.com/OmniSharp/omnisharp-vscode/issues/813。与此同时,您将需要使用Visual Studio来调试.NET Framework进程。