简体   繁体   English

无法安装 Npgsql (Visual Studio Code)

[英]Failed to install Npgsql (Visual Studio Code)

I'm having trouble with installing Npgsql in Visual Studio Code (.Net Core 3.1.1).我在 Visual Studio Code (.Net Core 3.1.1) 中安装 Npgsql 时遇到问题。

I create a clean project and try install package.我创建了一个干净的项目并尝试安装包。 dotnet new console dotnet add package Npgsql --version 4.1.2 dotnet new console dotnet add package Npgsql --version 4.1.2

The package fails to install and I receive a message:软件包安装失败,我收到一条消息:

The Npgsql package is not compatible with all architectures in the project.. I found a similar problem here, but it was solved by updating NuGet. Npgsql包并不是项目中所有架构都兼容。。我在这里发现了一个类似的问题,但是通过更新NuGet解决了。 Which probably won't be my case.这可能不是我的情况。 What am I doing wrong and how to install the package?我做错了什么以及如何安装软件包?

Problem solved.问题解决了。 Installing a package using the dotnet add package package-name command does not work for me.使用dotnet add package package-name命令安装包对我不起作用。 But if I install the NuGet Gallery extension (in the VS code) and add a package using this tool, then the library will install properly.但是如果我安装 NuGet Gallery 扩展(在 VS 代码中)并使用这个工具添加一个包,那么库将正确安装。

May be you need to provide more details about the environment, the platform you are using.您可能需要提供有关环境、您正在使用的平台的更多详细信息。 I tried creating the same on windows 10 with dot net 3.1.100 and it added the package successfully using visual studio code and VS 2019.我尝试使用 dot net 3.1.100 在 Windows 10 上创建相同的包,它使用 Visual Studio 代码和 VS 2019 成功添加了包。

<Project Sdk="Microsoft.NET.Sdk">

   <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>netcoreapp3.1</TargetFramework>
   </PropertyGroup>

   <ItemGroup>
      <PackageReference Include="npgsql" Version="4.1.2" />
   </ItemGroup>

</Project>

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

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