Search code examples
visual-studionugetnuget-package

Change nuget package content folder


I am not sure I have the terms quite right here, so give me some rope.

I have a class library project which when built with release config, generates a nuget package on build via the setting under project properties. Generate NuGet package on build setting

When I look at the package using nuget package explorer, the contents looks like this: Output contents

This makes sense, it matches the build folders output.

However what I am trying to achieve is changing that output to be lib\net462\plugins\dll.

Any ideas on the easiest way to achieve this? I cannot see any options for configuring the contents output on the package.


Solution

  • I have another auto generate method that can help you achieve the requirements you want.

    Since you are based on release, right click your project and then click 'Properties', go to 'Build Events', then using command like below in the 'Post-build event command line':

    cd ..
    cd ..
    dir
    nuget pack -OutputDirectory lib\net462\plugins\dll -Properties Configuration=Release
    

    The above is just an example/idea, it is using default package configurations, your situation may be a little different.

    For detailed information about the nuget pack, please refer to this official document:

    pack command (NuGet CLI)

    As you can see, I can generate the package to the path I want:

    enter image description here

    The above method is useful for many different types of projects.

    By the way, the UI between you and me is different, on my side, there is no 'Package' section in the project properties(netframework class library):

    enter image description here

    So please share your VS version and if possible, please also share a screenshot of the project type you selected.