Search code examples
.netvisual-studionugetpublish.net-standard

Is there a way to publish a .NET Standard Library without producing a .nupkg in Visual Studio 2019?


My understanding is that when you publish a .NET Standard Library, the expected behavior is to produce a .nupkg.

I have internal .Net Standard libraries that I maintain for use on in-house projects. A typical workflow would be to publish the libraries and then copy the published files to consuming projects. Is this not the way I should be doing things? I'm a bit confused by the lack of options when publishing a .NET Standard Library -- being that there is a .nupkg without a choice to publish in a different form.

What I want to get from publish is just a collection of necessary library files in the publish directory (not inside a nupkg). Is there a way to do this?


Solution

  • My understanding is that when you publish a .Net Standard Library, the expected behavior is to produce a .nupkg. What I want to get from publish is just a collection of necessary library files in the publish directory (not inside a nupkg). Is there a way to do this?

    For normal .net framework projects, if you reference one nuget package and build it. You then get a output folder(bin\debug or bin\release) with the Project.dll and Package.dll in it. And that's what you want.

    But for .net standard project, it will only output the Project.dll by default. Also it's intended behavior, see comment1, comment2. And that's why I suggest you need to manually edit the xx.csproj to get your expected behavior during build. That's by design that it won't copy the nuget dependencies to output, and this is the workaround that may meet your needs.

    As for why the publish output is a xx.nupkg when you right-click project node=>Publish in VS IDE(.net standard project), please check this document:The primary distribution vehicle for the .NET Standard reference assemblies is NuGet packages. I assume that's why the output of Publish is a xx.nupkg, hard to say but, it could be by design...

    Edit:

    Is there a way to publish a .Net Standard Library without producing a .nupkg in Visual Studio 2019?

    If you're referring to the Publish option for .net standard project.(Right click the project name of .net standard project in Solution Explorer=>Publish). I'm afraid the answer is negative. This option is by design and for now no other options like publish a folder with all referenced assemblies are supported. You may need to add a Feature Request in DC.

    Hope my clarifications make some help and if I misunderstand anything, feel free to correct me :(