C# 使用.NET核心和visual studio代码安装NuGet软件包失败
我在ubuntu上,我使用VSCode和.NET内核, 我用命令面板安装了一个名为Otter的软件包 我的.csproj现在是这样的:C# 使用.NET核心和visual studio代码安装NuGet软件包失败,c#,ubuntu,visual-studio-code,.net-core,nuget,C#,Ubuntu,Visual Studio Code,.net Core,Nuget,我在ubuntu上,我使用VSCode和.NET内核, 我用命令面板安装了一个名为Otter的软件包 我的.csproj现在是这样的: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp2.1</TargetFramework> </P
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Otter" Version="0.9.8.926"/>
</ItemGroup>
但当我尝试使用以下工具构建项目时:
dotnet build
我收到这个错误:
Program.cs(2,7): error CS0246: The type or namespace name 'Otter' could not be found (are you missing a using directive or an assembly reference?) [/home/erwan/Documents/helloWorldFromCSharp/helloWorldFromCSharp.csproj]
我不知道如何解决这个问题。我用一个简单的.Net核心应用程序测试了这个问题。我也有同样的问题 Otter在.NETFramework4.5中,因此不能与Asp.Net核心应用程序一起使用
由于您使用的是Ubuntu,您不能只切换到Asp.Net MVC。我建议您寻找另一个用.Net Core或.Net标准编写的2d框架(不知道是否可行)查看
Otter.csproj
:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
v4.5
也就是说,您不能从编译到netcoreapp2.1
如果可能的话,您可能希望克隆项目并尝试将其定位到合适的框架版本。在生成之前尝试使用
dotnet restore
。检查依赖项是否安装良好。完成,但我有相同的错误。我看到Otter上次更新是从2016年4月开始的。Otter在.net Core中可用吗?或者是.net framework?它是eems在.NET Core中不可用,所以我只需要完成项目并更改目标框架版本?好吧,您可以尝试,但我认为这不会那么容易。
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>