1

我有这个项目,ASP.NET MVC5 WebApi,它是使用 Visual Studio 2015 创建的。

<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>

碰巧我暂时无法使用 VS2015 工作,所以我现在正在使用 Visual Studio Code。

我能够配置我工作所需的几乎所有东西,OmniSharp 工作正常,所以我有智能感知,我能够使用 msbuild 构建解决方案并运行 IIS Express 来测试工作。除了调试之外我需要的一切。=/

我实际上可以将 vscode 附加到 iisexpress 实例,但它将断点保持为灰色,表示没有加载任何符号。我尝试在附加配置中使用symbolPath,但没有成功。

所有调试控制台都说:

--------------------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (clrdbg) with Visual Studio
Code, Visual Studio or Visual Studio for Mac software to help you develop and
test your applications.
--------------------------------------------------------------------------------

也许 clrdbg 不能针对 .NET 4.5.2?也许他们需要更多关于如何加载符号的信息?也许我错过了 iisexpress 命令行上的指令?

任何帮助将不胜感激。谢谢。:)

这是我的构建方式:(它们都可以正常工作

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "cmd",
    "isShellCommand": true,
    "args": ["/c"],
    "showOutput": "always",
    "tasks": [
        {
            "taskName": "build",
            "isBuildCommand": true,
            "suppressTaskName": true,
            "args": [
                "dotnet build",
                "${workspaceRoot}\\MyWebApi.sln"
            ],
            "showOutput": "always",
            "problemMatcher": "$msCompile"
        },
        {
            "taskName": "build with msbuild",
            "isBuildCommand": true,
            "suppressTaskName": true,
            "args": [
                "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe",
                "${workspaceRoot}\\MyWebApi.sln",
                "/p:Configuration=Debug;GenerateFullPaths=true",
                "/t:Rebuild",
                "/m",
                "/v:m",
                "/property:GenerateFullPaths=true"
            ],
            "showOutput": "always",
            "problemMatcher": "$msCompile"
        }
    ]
}

这是我运行 iisexpress 的方式:

"C:\Program Files\IIS Express\iisexpress.exe" /config:".\.vs\config\applicationhost.config" /site:MyWebApi /apppool:Clr4IntegratedAppPool /trace:e

这里我如何附加:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to IIS Express",
            "type": "coreclr",
            "request": "attach",
            "processName": "iisexpress"
        }
    ]
}
4

2 回答 2

0

请注意,现在可以使用C# for Visual Studio CodeOmniSharp 的扩展在 Visual Studio Code 中调试 C# 代码。到目前为止,我所看到的体验实际上非常好:

https://blogs.msdn.microsoft.com/visualstudioalm/2016/03/10/experimental-net-core-debugging-in-vs-code/

于 2017-04-07T21:06:09.280 回答
0

随着 OmniSharp 现在支持使用 C# 扩展进行调试,我能够使用 IIS 调试 c#。

我的设置与您的非常相似,但是,launch.json将类型行从 更改"type": "coreclr""type": "clr"。这应该让您调试 .NET 框架项目,无论它们是否使用 IIS。

于 2017-11-29T15:39:33.347 回答