[英]Install NuGet package with .NET CORE and visual studio code failed
I am on ubuntu and I use VSCode and .NET CORE, I installed a package called Otter with the command panel. 我在ubuntu上,使用VSCode和.NET CORE,我在命令面板上安装了名为Otter的软件包。
My .csproj is now like this : 我的.csproj现在是这样的:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Otter" Version="0.9.8.926"/>
</ItemGroup>
My main .cs file is : 我的主要.cs文件是:
using System;
using Otter;
namespace helloWorldFromCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
}
}
}
But when I try to build my project with : 但是当我尝试使用以下命令构建项目时:
dotnet build
I receive this error : 我收到此错误:
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]
I don"t know how to fix it. 我不知道该如何解决。
I tested with a simple .Net Core App to reproduce the problem. 我使用一个简单的.Net Core应用程序进行了测试,以重现该问题。 I have the same issue.
我有同样的问题。
Otter is in .Net Framework 4.5, so It won't work with an Asp.Net Core Application. Otter位于.Net Framework 4.5中,因此它将无法与Asp.Net Core应用程序一起使用。
Since you are on Ubuntu, you can't just switch to Asp.Net MVC. 由于您使用的是Ubuntu,因此不能只切换到Asp.Net MVC。 I recommend you to look for another 2d framework wrote in .Net Core or in .Net Standard (don't know if it is possible)
我建议您寻找以.Net Core或.Net Standard编写的另一个2d框架(不知道是否可能)
Looking at Otter.csproj
: 看
Otter.csproj
:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
Meaning, you can't reference it from a project that compiles to netcoreapp2.1
意思是,您不能从编译为
netcoreapp2.1
的项目中引用它
You might want to clone the project and try to target it to a suitable framework version, if possible. 您可能想要克隆项目,并尝试将其定位到合适的框架版本(如果可能)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.