VS代码无法在Ubuntu中找到.Net 6-无法编译和运行应用程序

e37o9pze  于 2023-02-03  发布在  .NET
关注(0)|答案(2)|浏览(250)

我正在运行Ubuntu 20.04、vscode和. net 6。当我尝试在vs studio中加载我的应用程序时,我收到以下错误:

[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/one/github/ion/Migration/Tests/Migrator.Tests/Migrator.Tests.csproj'.
/home/one/github/ion/GCPMigration/Tests/AwsMigrator.Tests/Migrator.Tests.csproj
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(1232,5): Error: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.

并且在我的屏幕中,我没有得到"生成用于构建和调试的C#资产"的选项:

我成功安装了.net6:

% dotnet --list-sdks
3.1.424 [/usr/share/dotnet/sdk]
6.0.405 [/usr/share/dotnet/sdk]

我在项目的根目录下创建了一个global.json文件:

{
    "sdk": {
      "version": "6.0.405"
    }
  }

然后我重新启动了VS代码,但仍然没有成功。我怎样才能让VS代码找到。net 6?

    • 更新**:以下是更多输出:

一个三个三个一个

    • 更新2**:
% code -s
[165406:0130/112324.020541:ERROR:bus.cc(398)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[165406:0130/112324.020669:ERROR:bus.cc(398)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[165406:0130/112324.024558:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
[165438:0130/112324.116599:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
[165474:0130/112324.239777:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
[165543:0130/112324.277406:WARNING:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process.
[165543:0130/112324.283025:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
Version:          Code 1.73.0 (8fa188b2b301d36553cbc9ce1b0a146ccb93351f, 2022-11-01T15:44:09.336Z)
OS Version:       Linux x64 5.4.0-137-generic
CPUs:             AMD Ryzen 5 2600 Six-Core Processor (11 x 3393)
Memory (System):  38.26GB (36.34GB free)
Load (avg):       1, 0, 0
VM:               0%
Screen Reader:    no
Process Argv:     . --crash-reporter-id 12ef4ab5-5c49-4439-9359-bc412e87bbfd
GPU Status:       2d_canvas:                              unavailable_software
                  canvas_oop_rasterization:               disabled_off
                  direct_rendering_display_compositor:    disabled_off_ok
                  gpu_compositing:                        disabled_software
                  multiple_raster_threads:                enabled_on
                  opengl:                                 disabled_off
                  rasterization:                          disabled_software
                  raw_draw:                               disabled_off_ok
                  skia_renderer:                          enabled_on
                  video_decode:                           disabled_software
                  video_encode:                           disabled_software
                  vulkan:                                 disabled_off
                  webgl:                                  unavailable_software
                  webgl2:                                 unavailable_software
                  webgpu:                                 disabled_off

CPU %   Mem MB     PID  Process
    0      118  165016  code main
    0       39  165021     zygote
    3      118  165088       gpu-process
    0       39  165022     zygote
    0        0  165024       zygote
    0       39  165079     utility-network-service
    0      313  165116     window (global.json - Migration - Visual Studio Code)
    0      157  165137     shared-process
    0       39  165168       ptyHost
    0        0  165365         /usr/bin/zsh -i
    0        0  165389           sh /usr/bin/code -s
    0       39  165394             /usr/share/code/bin/../code /usr/share/code/bin/../resources/app/out/cli.js --ms-enable-electron-run-as-node -s
    0      118  165406               /usr/share/code/code -s --enable-crashpad
    0       39  165409                 zygote
    0       39  165474                   gpu-process
    0       39  165410                 zygote
    0        0  165412                   zygote
    0       39  165472                 utility-network-service
    0        0  165486                 /bin/sh -c /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
    0        0  165487                   /usr/bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command=
    0       39  165209       fileWatcher
    0      118  165138     extensionHost
    0       39  165208       /usr/share/code/code --ms-enable-electron-run-as-node /usr/share/code/resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=165138
    0      157  165317       mono --assembly-loader=strict /home/one/.vscode/extensions/ms-dotnettools.csharp-1.25.4-linux-x64/.omnisharp/1.39.4/omnisharp/OmniSharp.exe -z -s /home/one/github/ion/Migration/Migrator.sln --hostPID 165138 DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information --plugin /home/one/.vscode/extensions/ms-dotnettools.csharp-1.25.4-linux-x64/.razor/OmniSharpPlugin/Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll FileOptions:SystemExcludeSearchPatterns:0=**/.git FileOptions:SystemExcludeSearchPatterns:1=**/.svn FileOptions:SystemExcludeSearchPatterns:2=**/.hg FileOptions:SystemExcludeSearchPatterns:3=**/CVS FileOptions:SystemExcludeSearchPatterns:4=**/.DS_Store FileOptions:SystemExcludeSearchPatterns:5=**/Thumbs.db FormattingOptions:EnableEditorConfigSupport=true formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4

Workspace Stats: 
|  Window (global.json - Migration - Visual Studio Code)
|    Folder (Migration): 82 files
|      File types: cs(32) json(9) md(9) csproj(2) bat(2) yml(2)
|                  gitattributes(1) gitignore(1) sln(1) cake(1)
|      Conf files: csproj(2) sln(1) dockerfile(1)
0md85ypi

0md85ypi1#

请检查VS代码中安装的CSharp扩展(使用OmniSharp)的版本。

code --list-extensions --show-versions

也许可以通过运行VS代码,然后并行运行以下命令来获得更多信息:

code -s | grep dotnet

返回的内容也是

dotnet --info
更新:

omnisharp.useModernNet选项设置为true解决了问题。

hs1rzwqc

hs1rzwqc2#

我给你的建议是使用Rider而不是VSCode,特别是在ubuntu中。你可以从
https://www.jetbrains.com/help/rider/Installation_guide.html
我得到了这个错误,我花了很多时间来修复它,但从来没有找到解决方案。

相关问题