Need example for Pack Target of MSBuild RRS feed

  • Question

  • I have a VS 2019 Solution with some .Net Framework 4.7.2 library projects. I need to create a NuGet Package after building each project in the solution. I came to know about Pack Target in MSBuild. But I didn't get any sample / code to achieve this. I would need help with 3 things.

    1. A Sample .Net Framework 4.7.2 Class Library Project (VS2019) with NuGet Pack Target implemented

    2. How to pass the various properties like Id, Name, Author, Version, Description etc?

    3. Is there a way to customize which files should be included in this package? If yes, how?

    Please help.


    Thursday, January 16, 2020 1:34 PM

All replies

  • Hi Venh,

    Welcome to MSDN forum.

    For 1 and 2, you could refer this doc:Create a NuGet package using MSBuild. From this doc, you need to add the properties into csproj file, then you could use msbuild line to set them,which is like:

    msbuild -t:pack -p:PackageID=xxx

    For 3, you could use nuspec file to pack specified files, please refer here:.nuspec reference, but you won't custom properties of packages using msbuild command.

    Any feedback will be expected.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, January 17, 2020 6:31 AM