我有一个针对.NET Framework 4的项目。我正在使用nuget.exe(版本5.6.0.6591)创建NuGet包。该项目本身没有其他引用,只有Microsoft.CSharp和System程序集(这些程序集都没有设置特定版本)。
首先,我创建了一个MyProject.nuspec文件(通过在MyProject.csproj文件夹中运行nuget spec)。然后我尝试运行nuget pack MyProject.csproj并获得了NuGet包(.nupkg存档)。但是我也收到了这个警告:
根据https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128,我已经修改了我的
然而,我仍然收到警告。当我在生成的
我找到的一个解决方法是,在
无论哪种方式,当我使用
似乎当我在
有什么想法可以解决警告,同时让
首先,我创建了一个MyProject.nuspec文件(通过在MyProject.csproj文件夹中运行nuget spec)。然后我尝试运行nuget pack MyProject.csproj并获得了NuGet包(.nupkg存档)。但是我也收到了这个警告:
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.0 to the nuspec
根据https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128,我已经修改了我的
.nuspec
文件,现在它看起来像这样(注意<dependencies>
标签):<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2020</copyright>
<tags>my tags here</tags>
<dependencies>
<group targetFramework=".NETFramework4.0" />
</dependencies>
</metadata>
</package>
然而,我仍然收到警告。当我在生成的
.nupkg
档案中打开.nuspec
文件时,那里只有空的<dependencies />
标签。我找到的一个解决方法是,在
.nuspec
文件中替换变量并调用nuget pack MyProject.nuspec
,而不是nuget pack MyProject.csproj
。然后我会得到相同的.nuspec
文件,包括目标框架依赖项,在我的结果.nupkg
档案中。但这使我失去了让nuget
自动为我填写版本的功能。无论哪种方式,当我使用
-Verbosity detailed
运行nuget pack
时,我看到Dependendecies
为空:Id: MyId
Version: 1.0.0
Authors: Me
Description: My description
Tags: my, tags, here
Dependencies:
似乎当我在
.csproj
上调用nuget pack
时,它会填充变量,但它也会删除依赖项,因为它认为它们是空的,然后它会给我警告。如果我在.nuspec
上调用nuget pack
,它会按原样打包,包括依赖项,从而避免警告。有什么想法可以解决警告,同时让
nuget
填充变量?如果我的软件包中没有指定目标框架,对于使用该软件包的任何人是否会产生负面影响?