繁体   English   中英

Visual Studio 代码 C# 在 Ubuntu 上构建错误

[英]Visual Studio Code C# build Error On Ubuntu

去年我在 Ubuntu 18.04 上成功安装了 Visual Studio Code 以使用 Python 进行开发。

昨天我安装了“.NET Core for C# 在 Linux 上编码”,所以我可以用 Visual Studio Code 编码 C#。

此处显示的工作区目录内容: http://fortitudevolution.com/VisualStudioCode/images/Selection_999(3031).png

我正在使用这个task.json文件位于parentdirectory/.vscode/tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "clean",
            "command": "dotnet clean",
            "type": "shell",
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "build",
            "command": "dotnet build",
            "type": "shell",
            "dependsOn": "clean",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "clean release",
            "command": "dotnet clean --configuration Release",
            "type": "shell",
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "publish",
            "command": "dotnet publish --configuration Release",
            "type": "shell",
            "dependsOn": "clean release",
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "runFunctionsHost",
            "type": "shell",
            "dependsOn": "build",
            "options": {
                "cwd": "${workspaceFolder}/bin/Debug/netstandard2.0"
            },
            "command": "func host start",
            "isBackground": true,
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$func-watch"
        }
    ]
}

对于目录内容中显示的应用程序代码Program.cs ,我在运行“终端 -> 运行构建任务”时收到此错误:

在文件夹 C# 中执行任务:dotnet clean

适用于 .NET 的 Microsoft (R) Build Engine 版本 16.9.0+57a23d249 版权所有 (C) Microsoft Corporation。 版权所有。

MSBUILD:错误 MSB1003:指定项目或解决方案文件。 当前工作目录不包含项目或解决方案文件。

终端进程“/bin/bash '-c', 'dotnet clean'”以退出代码终止:1。

终端将被任务重用,按任意键关闭它。

我将不胜感激任何帮助解决这个问题。

对于tasks数组中的每个command ,添加${workspaceFolder} 因此dotnet clean的第一个命令变为dotnet clean ${workspaceFolder}等等。 这告诉dotnet命令从哪个目录工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM