C# WinExe的VSCode tasks.json和launch.json依赖于dll

C# WinExe的VSCode tasks.json和launch.json依赖于dll,c#,json,visual-studio-code,vscode-debugger,vscode-tasks,C#,Json,Visual Studio Code,Vscode Debugger,Vscode Tasks,为了学习,我正在尝试为VSCode编写tasks.json和launch.json来构建这个项目: 有两个.csproj-一个构建“库”,另一个构建“WinExe”,它依赖于库 生成成功,但调试器未启动.exe,并出现以下错误: Error processing 'configurationDone' request. Unknown Error: 0x80131c30 使用此cli: dotnet build Mm.ExportableDataGrid\Mm.ExportableDataGr

为了学习,我正在尝试为VSCode编写tasks.json和launch.json来构建这个项目:

有两个.csproj-一个构建“库”,另一个构建“WinExe”,它依赖于库

生成成功,但调试器未启动.exe,并出现以下错误:

Error processing 'configurationDone' request. Unknown Error: 0x80131c30
使用此cli:

dotnet build Mm.ExportableDataGrid\Mm.ExportableDataGrid.csproj
dotnet build Mm.ExportableDataGrid.Wpf\Mm.ExportableDataGrid.Wpf.csproj
我发现以下错误:

CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(13,13): error CS0103: The name 'InitializeComponent' does not exist in the current context [C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
C:\Users\userid\C-Sharp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\MainWindow.xaml.cs(52,13): error CS0103: The name 'dataGrid' does not exist in the current context [C:\Users\userid\C-Sharp Prp Projects\ExportableDataGrid\mm.exportabledatagrid.wpf\mm.exportabledatagrid.wpf.csproj]
launch.json和tasks.json都位于根文件夹中,其中包含github归档中的两个文件夹

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Custom .NET Launcher",
            "type": "clr",
            "request": "launch",
            "preLaunchTask": "buildExe",
            "program": "${workspaceFolder}/Mm.ExportableDataGrid.Wpf/bin/Debug/Mm.ExportableDataGrid.Wpf.exe",
            "args": [],
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopAtEntry": false
        }
    ]
}
{
    "version": "2.0.0",
    "tasks": [
        {
            "label":"buildDll",
            "type":"shell",
            "command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
            "presentation":{
                "clear":true
                },
            "args":[
                "Mm.ExportableDataGrid\\Mm.ExportableDataGrid.csproj",
                "/t:Build",
                "/p:Configuration=Debug",
                "/p:Platform=\"AnyCPU\""
            ]
        },
        {
            "label":"buildExe",
            "type":"shell",
            "command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
            "presentation":{
                "clear":true
                },
            "dependsOn":"buildDll",
            "args":[
                "Mm.ExportableDataGrid.Wpf\\Mm.ExportableDataGrid.Wpf.csproj",
                "/t:Build",
                "/p:Configuration=Debug",
                "/p:Platform=\"AnyCPU\""
            ]
        }
    ]
}
tasks.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Custom .NET Launcher",
            "type": "clr",
            "request": "launch",
            "preLaunchTask": "buildExe",
            "program": "${workspaceFolder}/Mm.ExportableDataGrid.Wpf/bin/Debug/Mm.ExportableDataGrid.Wpf.exe",
            "args": [],
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopAtEntry": false
        }
    ]
}
{
    "version": "2.0.0",
    "tasks": [
        {
            "label":"buildDll",
            "type":"shell",
            "command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
            "presentation":{
                "clear":true
                },
            "args":[
                "Mm.ExportableDataGrid\\Mm.ExportableDataGrid.csproj",
                "/t:Build",
                "/p:Configuration=Debug",
                "/p:Platform=\"AnyCPU\""
            ]
        },
        {
            "label":"buildExe",
            "type":"shell",
            "command":"C:/\"Program Files (x86)/\"Microsoft Visual Studio\"/2019/BuildTools/MSBuild/Current/Bin/MSBuild.exe",
            "presentation":{
                "clear":true
                },
            "dependsOn":"buildDll",
            "args":[
                "Mm.ExportableDataGrid.Wpf\\Mm.ExportableDataGrid.Wpf.csproj",
                "/t:Build",
                "/p:Configuration=Debug",
                "/p:Platform=\"AnyCPU\""
            ]
        }
    ]
}
尽管读了很多书,我还是搞不懂这里发生了什么

  • 如何调试0x80131c30错误
  • 为什么会出现CS5001错误

  • 此外,我能够运行无调试,没有问题。似乎是附加调试器时出现问题。

    我在遇到问题数周后才发现问题

    修复方法是创建一个指定“x64”的“My_Project.runsettings”文件,并在解决方案的settings.json中使用“omnisharp.testRunSettings”引用该文件:“Path_to_My_file\My_Project.runsettings”


    详细解释请参见我在github上的回答:

    没有任务
    buildExe
    my bad,但我不小心从帖子中删掉了它。更新。