2

I'm new to creating NuGet packages and have only been playing around with them for a couple of days, as it now stands I've tested my package on .NET Frameworks 3.5 through 4.8 successfully.

By the way, this is the package: https://www.nuget.org/packages/ExcelFromList/1.0.4

My package relies on EPPlus, which is what I use as the engine. If you search for EPPlus you will see that it states that it can be installed on .NET Framework, .NET Standard, and .NET Core, I have tested this and it's correct.

So I'm not sure how to pull this off.

This is the info on my project:

  • Project is .NET 3.5
  • Using nuget.exe to create the NuGet package
  • Using .nuspec file for package creation (nuget pack <.nuspec file>)
  • Only NuGet package installed in project is EPPLus

This is my .nuspec file:

<?xml version="1.0" encoding="utf-8" ?>
<package>
  <metadata>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <id>ExcelFromList</id>
    <version>1.0.4</version>
    <title>ExcelFromList</title>
    <description>Straightforward and easy way to create stylized excel workbooks from lists. Add an image, title, subtitles and overal cell styles/formats. Uses the EPPlus engine.</description>
    <releaseNotes>Succesfully tested on .NET frameworks from 3.5 through 4.8</releaseNotes>
    <authors>Raul Marquez</authors>
    <owners>Raul Marquez</owners>
    <copyright>Copyright 2020 Raul Marquez</copyright>
    <projectUrl>https://github.com/RaulMarquezInclan/ExcelFromList</projectUrl>
    <license type="expression">GPL-3.0-only</license>
    <tags>excel list listtoexcel</tags>

    <dependencies>
      <dependency id="EPPlus" version="5.1.0" />
    </dependencies>

  </metadata>

  <files>
    <file src="bin\Debug\net35\ExcelFromList.dll" target="lib\net35" />
    <file src="bin\Debug\net35\ExcelFromList.xml" target="lib\net35" />
  </files>
</package>

Building the package with that configuration throws me this warning:

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 .NETFramework3.5 to the nuspec

However, as I stated before, it still installs and runs just fine throughout the different .NET Framework versions.

When attempting to install it on .NET Standard or .NET Core it will install my dll correctly but it won't install EPPlus, which is a dependency of my package. On the .NET Standard side, I only have to manually install it and all is good, on the .NET Core side after doing the same it tells me that the executable cant run in the project.

So, where I'm confused is on how to also make them available to .NET Standard and .NET core, from searching around I've gotten hints about converting it to a .NET standard in the first place, or having three different dlls each corresponding the the different technologies and specifying them in the files section of the .nuspec file, etc.

Can anyone please point me in the right direction?

EDIT: By the way, when looking at the EPPlus package this is what we see:

EPPLus

Thanks.

2
  • Don't know. I had the same thing with a UWP library package. I ignored it after a couple attempts to fix it as the impact seemed pretty minimal. Likewise I doubt you'd have the same issue if you converted it to .net standard but it might not be worth the effort per se. It's very easy to make nuget packages when working with .net standard. Commented Apr 11, 2020 at 14:24
  • I don't think you will get this working without any changes to your .net framework based project file. I have come across this article medium.com/@SicknoteSteve/… . This could be a similar issue to what you are facing as you need to enable your library aware of .net standard/.Net core Commented Jun 29, 2020 at 12:42

1 Answer 1

2

You can, if you upgrade your .csproj file to the "new" .csproj file format. I'd highly recommend you do that; the new project format is greatly simplified and easier to use.

In this new format, you can target multiple frameworks, like this:

  <PropertyGroup>
    <TargetFrameworks>netstandard2.1;netstandard2.0;net45;net40;net35</TargetFrameworks>
  </PropertyGroup>

The EPPlus project file is a great example of how to do multi-targetting.

You can then build your package by running dotnet pack, and it will automatically create a NuGet package which targets all of the versions of .NET listed in TargetFrameworks.

You will need to use the .NET Core SDK to build your project, but you can still run your package on desktop .NET.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.