NuGet:使用 .NET Framework 而不是 net5.0 恢复了包
NuGet: Package was restored using .NET Framework instead of net5.0
我是 .NET core 和 NuGet 发布的新手。
- 我构建了一个 .NET Core 5.0 class 库。
- 我构建了一个 .NET Core 5.0 控制台应用程序来测试这个 class 库
- 如果测试控制台应用程序直接引用从此 class 库构建的 DLL,则一切正常。
- 如果我使用 class 库构建 NuGet 包并发布它,然后将该包下载到测试控制台应用程序,我会收到此警告:
"包 SkyBridge.ClientAPI.NetCore 1.0.0.3 已使用
.NETFramework,版本=v4.6.1,
.NETFramework,版本=v4.6.2,
.NETFramework,版本=v4.7,
.NETFramework,版本=v4.7.1,
.NETFramework,版本=v4.7.2,
.NETFramework,版本=v4.8
而不是项目目标框架net5.0。
此包可能与您的项目不完全兼容。"
这是 nuspec 文件:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>SkyBridge.ClientAPI.NetCore</id>
<version>1.0.0.3</version>
<title>SkyBridge.ClientAPI (.NET Core)</title>
<authors>Front Edge Software, Frank Lieu</authors>
<owners>Front Edge Software, Frank Lieu</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">SkyBridge_Client_API_Software_License_Agreement.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</description>
<summary>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</summary>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright ©2021 Front Edge Software</copyright>
<tags>Front Edge SkyBridge Client API Remoting</tags>
<dependencies>
<dependency id="Crc32.NET" version="1.2.0" />
<dependency id="BouncyCastle.NetCore" version="1.8.10" />
<dependency id="BouncyCastle.NetCoreSdk" version="1.9.3.1" />
<dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
</dependencies>
</metadata>
<files>
<file src="SkyBridge_Client_API_Software_License_Agreement.txt" target="" />
</files>
</package>
有什么问题?
以下 nuspec 解决了问题 - 我指定了 .NET 依赖项:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>SkyBridgeAPI.NetCore</id>
<version>1.0.0.6</version>
<title>SkyBridgeAPI (.NET Core)</title>
<authors>Front Edge Software, Frank Lieu</authors>
<owners>Front Edge Software, Frank Lieu</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">SkyBridgeAPI_Software_License_Agreement.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</description>
<summary>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</summary>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright ©2021 Front Edge Software</copyright>
<tags>Front Edge SkyBridge API Remoting</tags>
<dependencies>
<group targetFramework="net5.0">
<dependency id="Crc32.NET" version="1.2.0" />
<dependency id="BouncyCastle.NetCore" version="1.8.10" />
<dependency id="BouncyCastle.NetCoreSdk" version="1.9.3.1" />
<dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="SkyBridgeAPI_Software_License_Agreement.txt" target="" />
<file src="lib\net5.0\FrontEdge.SkyBridgeAPI.dll" target="lib\net5.0" />
</files>
</package>
我是 .NET core 和 NuGet 发布的新手。
- 我构建了一个 .NET Core 5.0 class 库。
- 我构建了一个 .NET Core 5.0 控制台应用程序来测试这个 class 库
- 如果测试控制台应用程序直接引用从此 class 库构建的 DLL,则一切正常。
- 如果我使用 class 库构建 NuGet 包并发布它,然后将该包下载到测试控制台应用程序,我会收到此警告:
"包 SkyBridge.ClientAPI.NetCore 1.0.0.3 已使用 .NETFramework,版本=v4.6.1, .NETFramework,版本=v4.6.2, .NETFramework,版本=v4.7, .NETFramework,版本=v4.7.1, .NETFramework,版本=v4.7.2, .NETFramework,版本=v4.8 而不是项目目标框架net5.0。 此包可能与您的项目不完全兼容。"
这是 nuspec 文件:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>SkyBridge.ClientAPI.NetCore</id>
<version>1.0.0.3</version>
<title>SkyBridge.ClientAPI (.NET Core)</title>
<authors>Front Edge Software, Frank Lieu</authors>
<owners>Front Edge Software, Frank Lieu</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">SkyBridge_Client_API_Software_License_Agreement.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</description>
<summary>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</summary>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright ©2021 Front Edge Software</copyright>
<tags>Front Edge SkyBridge Client API Remoting</tags>
<dependencies>
<dependency id="Crc32.NET" version="1.2.0" />
<dependency id="BouncyCastle.NetCore" version="1.8.10" />
<dependency id="BouncyCastle.NetCoreSdk" version="1.9.3.1" />
<dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
</dependencies>
</metadata>
<files>
<file src="SkyBridge_Client_API_Software_License_Agreement.txt" target="" />
</files>
</package>
有什么问题?
以下 nuspec 解决了问题 - 我指定了 .NET 依赖项:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>SkyBridgeAPI.NetCore</id>
<version>1.0.0.6</version>
<title>SkyBridgeAPI (.NET Core)</title>
<authors>Front Edge Software, Frank Lieu</authors>
<owners>Front Edge Software, Frank Lieu</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">SkyBridgeAPI_Software_License_Agreement.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</description>
<summary>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</summary>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright ©2021 Front Edge Software</copyright>
<tags>Front Edge SkyBridge API Remoting</tags>
<dependencies>
<group targetFramework="net5.0">
<dependency id="Crc32.NET" version="1.2.0" />
<dependency id="BouncyCastle.NetCore" version="1.8.10" />
<dependency id="BouncyCastle.NetCoreSdk" version="1.9.3.1" />
<dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="SkyBridgeAPI_Software_License_Agreement.txt" target="" />
<file src="lib\net5.0\FrontEdge.SkyBridgeAPI.dll" target="lib\net5.0" />
</files>
</package>