项目已构建,但Omnisharp没有看到nuget包并显示错误

问题描述 投票:0回答:1

我在linux上(elementaryOS,基于Ubuntu),并且同时安装了.NET Core(3.0.100)和Mono(6.4.0.198)。对于C#开发,我使用带有Omnisharp扩展名的VS Code。我正在尝试使用Xamarin.Forms构建sample project

我的问题是,即使我可以成功构建项目,Monosha仍在抱怨缺少Xamarin.Forms参考:

The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?) (CS0234)

我检查了它,它包含在.csproj中:

<ItemGroup>
  <PackageReference Include="Xamarin.Forms" Version="4.2.0.709249" />
</ItemGroup>

我的怀疑是Omnisharp可能尝试与.NET Core而不是Mono进行通信。 (由于我需要定位.NET Framework的版本,因此必须使用Mono构建它。)这就是我使用Mono构建项目的方式:

$ nuget restore
$ cd GameOfLife/GameOfLife
$ msbuild
$ cd ../GameOfLife.Android
$ msbuild /t:Build,Install

我知道我无法使用.NET Core构建项目,但是我至少尝试获取nuget包:

$ dotnet restore
→ ./GameOfLife/GameOfLife/GameOfLife.Android/GameOfLife.Android.csproj :
  warning NU1503: Skipping restore for project './GameOfLife/GameOfLife
  /GameOfLife.Android/GameOfLife.Android.csproj'. The project file may be
  invalid or missing targets required for restore. [./GameOfLife/GameOfLife.sln]

$ cd GameOfLife/GameOfLife.Android
$ dotnet restore
→ (nothing happened)

$ dotnet add GameOfLife.Android.csproj package Xamarin.Forms
→ ./GameOfLife/GameOfLife/GameOfLife.Android/GameOfLife.Android.csproj(85,3):
  error MSB4019: The imported project "/usr/share/dotnet/sdk/3.0.100/Xamarin
  /Android/Xamarin.Android.CSharp.targets" was not found. Confirm that the path
  in the <Import> declaration is correct, and that the file exists on disk.
→ Unable to create dependency graph file for project 'GameOfLife.Android.csproj'.
  Cannot add package reference.

[最后一个错误意味着Xamarin.Android仅为Mono安装((。不可能)为.NET Core安装),但是我不知道这是否阻止Xamarin.Forms的安装,或者是否只是一个相关的错误。

我在Linux(elementaryOS,基于Ubuntu的Linux)上,并同时安装了.NET Core(3.0.100)和Mono(6.4.0.198)。对于C#开发,我使用带有Omnisharp扩展名的VS Code。我正在尝试构建示例...
.net xamarin.forms .net-core mono omnisharp
1个回答
0
投票
关闭并重新打开VS Code😑后问题消失了
© www.soinside.com 2019 - 2024. All rights reserved.