Nuget - 包恢复失败。回滚“WebApplication1”的包更改。 0

问题描述 投票:48回答:2

这是我自己的定制nuget包,我还没有发布并在本地测试。

nuget包由dll文件和nuspec文件组成,如下所示。

<?xml version="1.0"?>
<package >
  <metadata>
    <id>MyLib</id>
    <version>1.0.0</version>
    <authors>Author</authors>
    <owners>Owner</owners>
    <licenseUrl>license url</licenseUrl>
    <projectUrl>project url</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>some description</copyright>
    <tags>Tag1 Tage2</tags>
  </metadata>
  <files>
    <file src="bin\Debug\netstandard1.4\*.dll" target="lib" />
    <file src="bin\Debug\netstandard1.4\*.pdb" target="lib" />
  </files>
</package>

我已将nupkg文件复制到某个位置并将其添加到

Visual studio Tools -> Options -> Packages -> sources directory 

错误:

Package MyLib 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package MyLib 1.0.0 supports: net (.NETFramework,Version=v0.0)
Package restore failed. Rolling back package changes for 'WebApplication1'.

不确定如何解决问题或查找更多信息。

更多信息

dll文件是使用模板(.Net Framework 4.5.2)创建的

Templates -> Visual C# -> .NET Core -> Class Library (.NET Standard)

Web应用程序是使用模板创建的。 (空Web应用程序)

Templates -> Visual C# -> .NET Core -> ASP.NET Core Web Application (.NET Core)

编辑

我在Output窗口下找到了更多细节

One or more packages are incompatible with .NETCoreApp,Version=v1.0.

我应该创建哪种与.NETCoreApp兼容的类库?

我懂了

我看到了这个URL。它建议使用dotnet.exe pack --no-build创建nupkg,而早些时候我从nuget.org下载了nuget.exe来创建包。

我尝试了上面的命令,但随后视觉工作室说

"... Target pack doesn't exists in the project ... "

也遵循本网站上的说明,但URL失败

c# nuget .net-core nuget-package-restore visual-studio-2017
2个回答
146
投票

您需要清除Nuget Cache。要执行此操作,请转到工具 - >选项,然后单击此图片enter image description here


19
投票

您的项目针对的是.Net Framework的不兼容版本。右键单击项目,选择属性并记下Target Framework的值。查看Microsoft的Nuget包,然后安装更合适的NuGet包。安装旧版本的NuGet软件包或更新项目以定位更新版本。

© www.soinside.com 2019 - 2024. All rights reserved.