Search code examples
.net-corenuget

NuGet: Package was restored using .NET Framework instead of net5.0


I am new to both .NET core and NuGet releasing.

  • I built a .NET Core 5.0 class library.
  • I built a .NET Core 5.0 console app to test this class library
  • If the test console app directly reference the DLL built from this class library, everything works fine.
  • If I build a NuGet package using the class library and release it, then download that package to the test console app, I get this warning:

"Package SkyBridge.ClientAPI.NetCore 1.0.0.3 was restored using .NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8 instead of the project target framework net5.0. This package may not be fully compatible with your project."

This is the nuspec file:

<?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>

What is the problem?


Solution

  • The following .nuspec solved the problem - I specified the .NET dependency:

    <?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>