我创建了一个类库,它针对 .net framework 4.6.1(基本上是一个空白画布),只有一个返回字符串的方法,用于测试目的。我想将其制作成 nuget 包。我正在按照这篇文章 https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio-net-framework 进行操作,但是当我运行 "nuget pack" 命令时,出现以下警告:
"WARNING: NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below:
- Add a dependency group for .NETFramework4.6.1 to the nuspec"
我尝试将依赖组添加到 .nuspec 文件中:
<?xml version="1.0"?>
<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Author</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>H</description>
<copyright>Copyright 2019</copyright>
<tags>blah</tags>
<dependencies>
<group targetFramework=".NETFramework4.6.1" />
</dependencies>
</metadata>
</package>
我也尝试过:
<?xml version="1.0"?>
<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Author</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>H</description>
<copyright>Copyright 2019</copyright>
<tags>blah</tags>
<dependencies>
<group targetFramework="net461" />
</dependencies>
</metadata>
</package>
我仍然遇到相同的错误。
我尝试使用旧版本的NuGet,但警告信息没有显示,但是问题仍然存在(如果我尝试通过包管理器添加,它会说它没有依赖项)。
TargetFramework
元素更改为使用net461
而不是netstandard2.0
。使用VS或dotnet.exe打包并查看是否存在相同的问题。 - zivkanmsbuild /t:pack
命令。我假设您正在使用带有packagereference的.net框架项目,那么您可以检查一下msbuild command
是否能够满足您的需求。希望能对您有所帮助 :-) - LoLance