[{"data":1,"prerenderedAt":556},["ShallowReactive",2],{"blog:2014:simple-steps-for-publishing-your-nuget-package":3,"blogMore-Development":484,"comments-simple-steps-for-publishing-your-nuget-package":497},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":17,"body":37,"_type":476,"_id":477,"_source":478,"_file":479,"_stem":480,"_extension":481,"url":482,"wordCount":483,"minutes":471,"commentCount":191},"/blog/2014/simple-steps-for-publishing-your-nuget-package","2014",false,"en","5 simple steps to publishing a NuGet package","There is a fair amount of info on making and publishing NuGet packages but I couldn’t find a simplified guide for the simple case. Here it is and start by downloading nuget.exe and putting it in your path.","2014-01-08T01:39:24+00:00","Development",[13,14,15,16],".NET","C#","Visual Studio","NuGet",{"type":18,"children":19},"root",[20,32],{"type":21,"tag":22,"props":23,"children":24},"element","p",{},[25,28,30],{"type":26,"value":27},"text","There is a fair amount of info on making and publishing NuGet packages but I couldn’t find a simplified guide for the simple case. Here it is and start by downloading ",{"type":26,"value":29},"nuget.exe",{"type":26,"value":31}," and putting it in your path.",{"type":21,"tag":22,"props":33,"children":34},{},[35],{"type":26,"value":36},"Supporting multiple platforms gives you a choice to make:",{"type":18,"children":38,"toc":465},[39,52,59,63,88,102,108,113,147,153,158,171,176,259,273,287,292,298,303,311,316,322,327,382,388,402,451,459],{"type":21,"tag":22,"props":40,"children":41},{},[42,43,51],{"type":26,"value":27},{"type":21,"tag":44,"props":45,"children":49},"a",{"href":46,"rel":47},"https://www.nuget.org",[48],"nofollow",[50],{"type":26,"value":29},{"type":26,"value":31},{"type":21,"tag":53,"props":54,"children":56},"h2",{"id":55},"_1-multi-platform-considerations-optional",[57],{"type":26,"value":58},"1. Multi-platform considerations (optional)",{"type":21,"tag":22,"props":60,"children":61},{},[62],{"type":26,"value":36},{"type":21,"tag":64,"props":65,"children":66},"ol",{},[67,78,83],{"type":21,"tag":68,"props":69,"children":70},"li",{},[71],{"type":21,"tag":44,"props":72,"children":75},{"href":73,"rel":74},"https://msdn.microsoft.com/en-us/library/vstudio/gg597391%28v=vs.110%29.aspx",[48],[76],{"type":26,"value":77},"Portable Class Library (PCL)",{"type":21,"tag":68,"props":79,"children":80},{},[81],{"type":26,"value":82},"One project with MSBuild magic",{"type":21,"tag":68,"props":84,"children":85},{},[86],{"type":26,"value":87},"Multiple projects",{"type":21,"tag":22,"props":89,"children":90},{},[91,93,100],{"type":26,"value":92},"If you can go with PCL do it. For ",{"type":21,"tag":44,"props":94,"children":97},{"href":95,"rel":96},"https://github.com/attackpattern/CSharpanalytics",[48],[98],{"type":26,"value":99},"CSharpAnalytics",{"type":26,"value":101}," we use platform-specific system info and hooks so it’s not an option, and we went with multiple projects.",{"type":21,"tag":103,"props":104,"children":106},"h3",{"id":105},"multiple-projects",[107],{"type":26,"value":87},{"type":21,"tag":22,"props":109,"children":110},{},[111],{"type":26,"value":112},"Creating a separate .csproj for each platform and putting in the same folder means adding files isn’t too painful (show all files then include the ones you need) but you do need to take steps to make sure the build process for the projects don’t interfere with each other by separating the bin and obj paths:",{"type":21,"tag":64,"props":114,"children":115},{},[116,128],{"type":21,"tag":68,"props":117,"children":118},{},[119,121],{"type":26,"value":120},"Set the output path in the Build tab of project properties to be unique per configuration to for the bin files, e.g. ",{"type":21,"tag":122,"props":123,"children":125},"code",{"className":124},[],[126],{"type":26,"value":127},"bin\\Net45\\Release\\",{"type":21,"tag":68,"props":129,"children":130},{},[131,133,139,141],{"type":26,"value":132},"Edit the .csproj file adding a ",{"type":21,"tag":122,"props":134,"children":136},{"className":135},[],[137],{"type":26,"value":138},"BaseIntermediateOutputPath",{"type":26,"value":140}," tag for obj files, e.g. ",{"type":21,"tag":122,"props":142,"children":144},{"className":143},[],[145],{"type":26,"value":146},"\u003CBaseIntermediateOutputPath>obj\\Net45\u003C/BaseIntermediateOutputPath>",{"type":21,"tag":53,"props":148,"children":150},{"id":149},"_2-create-your-nuspec-definition",[151],{"type":26,"value":152},"2. Create your .nuspec definition",{"type":21,"tag":22,"props":154,"children":155},{},[156],{"type":26,"value":157},"Now that you know which release dll files you need to include you can go ahead and create the nuspec file that tells nuget how to package your files up.",{"type":21,"tag":22,"props":159,"children":160},{},[161,163,169],{"type":26,"value":162},"Open a PowerShell and type ",{"type":21,"tag":122,"props":164,"children":166},{"className":165},[],[167],{"type":26,"value":168},"nuget spec",{"type":26,"value":170}," to create you an XML file to edit in your text editor",{"type":21,"tag":22,"props":172,"children":173},{},[174],{"type":26,"value":175},"Once you’ve entered your author details, a snappy description and links to your project page and license you can then add the files. Libraries will want to copy the .dlls into the lib folder with element like these:",{"type":21,"tag":177,"props":178,"children":183},"pre",{"code":179,"language":180,"meta":181,"className":182,"style":181},"\u003Cfile src=\"..\\bin\\Net45\\Release\\MyLibrary.dll\" target=\"lib\\net45\" />\n","xml","","language-xml shiki shiki-themes everforest-light dracula",[184],{"type":21,"tag":122,"props":185,"children":186},{"__ignoreMap":181},[187],{"type":21,"tag":188,"props":189,"children":192},"span",{"class":190,"line":191},"line",1,[193,199,205,211,216,222,228,232,237,241,245,250,254],{"type":21,"tag":188,"props":194,"children":196},{"style":195},"--shiki-default:#8DA101;--shiki-dark:#F8F8F2",[197],{"type":26,"value":198},"\u003C",{"type":21,"tag":188,"props":200,"children":202},{"style":201},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[203],{"type":26,"value":204},"file",{"type":21,"tag":188,"props":206,"children":208},{"style":207},"--shiki-default:#DFA000;--shiki-default-font-style:inherit;--shiki-dark:#50FA7B;--shiki-dark-font-style:italic",[209],{"type":26,"value":210}," src",{"type":21,"tag":188,"props":212,"children":213},{"style":195},[214],{"type":26,"value":215},"=",{"type":21,"tag":188,"props":217,"children":219},{"style":218},"--shiki-default:#8DA101;--shiki-dark:#E9F284",[220],{"type":26,"value":221},"\"",{"type":21,"tag":188,"props":223,"children":225},{"style":224},"--shiki-default:#8DA101;--shiki-dark:#F1FA8C",[226],{"type":26,"value":227},"..\\bin\\Net45\\Release\\MyLibrary.dll",{"type":21,"tag":188,"props":229,"children":230},{"style":218},[231],{"type":26,"value":221},{"type":21,"tag":188,"props":233,"children":234},{"style":207},[235],{"type":26,"value":236}," target",{"type":21,"tag":188,"props":238,"children":239},{"style":195},[240],{"type":26,"value":215},{"type":21,"tag":188,"props":242,"children":243},{"style":218},[244],{"type":26,"value":221},{"type":21,"tag":188,"props":246,"children":247},{"style":224},[248],{"type":26,"value":249},"lib\\net45",{"type":21,"tag":188,"props":251,"children":252},{"style":218},[253],{"type":26,"value":221},{"type":21,"tag":188,"props":255,"children":256},{"style":195},[257],{"type":26,"value":258}," />\n",{"type":21,"tag":22,"props":260,"children":261},{},[262,264,271],{"type":26,"value":263},"Each platform will require a specific target and they should use platform name (e.g. net45, sl5, windows8) described in the ",{"type":21,"tag":44,"props":265,"children":268},{"href":266,"rel":267},"https://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Common_Framework_and_Profile_Targeting_Examples",[48],[269],{"type":26,"value":270},"NuSpec creating packages documentation",{"type":26,"value":272},". That page has a lot more detail on things such as content file types etc.",{"type":21,"tag":22,"props":274,"children":275},{},[276,278,285],{"type":26,"value":277},"If you prefer a graphical UI then ",{"type":21,"tag":44,"props":279,"children":282},{"href":280,"rel":281},"https://docs.nuget.org/docs/creating-packages/using-a-gui-to-build-packages",[48],[283],{"type":26,"value":284},"NuGet Package Explorer",{"type":26,"value":286}," will make your life easier.",{"type":21,"tag":22,"props":288,"children":289},{},[290],{"type":26,"value":291},"Remember to check your .nuspec file to source control (there is nothing private in it) and add it to your solution as a solution item so it doesn’t get missed.",{"type":21,"tag":53,"props":293,"children":295},{"id":294},"_3-create-your-nupkg-package",[296],{"type":26,"value":297},"3. Create your .nupkg package",{"type":21,"tag":22,"props":299,"children":300},{},[301],{"type":26,"value":302},"The easiest part of the process. From PowerShell type:",{"type":21,"tag":177,"props":304,"children":306},{"code":305},"nuget pack yourfile.nuspec\n",[307],{"type":21,"tag":122,"props":308,"children":309},{"__ignoreMap":181},[310],{"type":26,"value":305},{"type":21,"tag":22,"props":312,"children":313},{},[314],{"type":26,"value":315},"If all goes well it will create yourfile.nupkg.",{"type":21,"tag":53,"props":317,"children":319},{"id":318},"_4-test-your-package",[320],{"type":26,"value":321},"4. Test your package",{"type":21,"tag":22,"props":323,"children":324},{},[325],{"type":26,"value":326},"Just because your package was created doesn’t mean it works and you don’t want to publish to the world until you know it works especially given you can’t delete packages from NuGet:",{"type":21,"tag":64,"props":328,"children":329},{},[330,341,352,365,377],{"type":21,"tag":68,"props":331,"children":332},{},[333,335],{"type":26,"value":334},"Create a folder to be your own private testing NuGet repository, e.g. ",{"type":21,"tag":122,"props":336,"children":338},{"className":337},[],[339],{"type":26,"value":340},"c:\\testnuget",{"type":21,"tag":68,"props":342,"children":343},{},[344,346],{"type":26,"value":345},"Publish to your test repository with ",{"type":21,"tag":122,"props":347,"children":349},{"className":348},[],[350],{"type":26,"value":351},"nuget push yourfile.nupkg -source c:\\testnuget",{"type":21,"tag":68,"props":353,"children":354},{},[355,357,363],{"type":26,"value":356},"Configure Visual Studio to use your test repository by going to ",{"type":21,"tag":358,"props":359,"children":360},"em",{},[361],{"type":26,"value":362},"Tools > Library Package Manager > Package Manager Settings > Package Sources",{"type":26,"value":364}," and then adding your test folder to the Available package sources test",{"type":21,"tag":68,"props":366,"children":367},{},[368,370,375],{"type":26,"value":369},"Create a new test application and then add a reference using ",{"type":21,"tag":358,"props":371,"children":372},{},[373],{"type":26,"value":374},"Manage NuGet Packages",{"type":26,"value":376}," to choose your new package from your test repository.",{"type":21,"tag":68,"props":378,"children":379},{},[380],{"type":26,"value":381},"Write a few lines of code to test you can actually use your package OK!",{"type":21,"tag":53,"props":383,"children":385},{"id":384},"_5-publish-to-the-world",[386],{"type":26,"value":387},"5. Publish to the world",{"type":21,"tag":22,"props":389,"children":390},{},[391,393,400],{"type":26,"value":392},"Okay, you’re now ready to publish. If you haven’t yet ",{"type":21,"tag":44,"props":394,"children":397},{"href":395,"rel":396},"https://www.nuget.org/users/account/LogOn",[48],[398],{"type":26,"value":399},"signed up for an account over at Nuget.org",{"type":26,"value":401}," you’ll need to do that first.",{"type":21,"tag":64,"props":403,"children":404},{},[405,419,438],{"type":21,"tag":68,"props":406,"children":407},{},[408,410,417],{"type":26,"value":409},"Go to ",{"type":21,"tag":44,"props":411,"children":414},{"href":412,"rel":413},"https://www.nuget.org/account",[48],[415],{"type":26,"value":416},"Your Account",{"type":26,"value":418}," and copy your API key",{"type":21,"tag":68,"props":420,"children":421},{},[422,424,430,432],{"type":26,"value":423},"Run the PowerShell command ",{"type":21,"tag":122,"props":425,"children":427},{"className":426},[],[428],{"type":26,"value":429},"nuget setApiKey",{"type":26,"value":431}," followed by your API key, e.g. ",{"type":21,"tag":122,"props":433,"children":435},{"className":434},[],[436],{"type":26,"value":437},"nuget setApiKey 99995594-38d2-42cd-a8b1-ddcd722bb7e7",{"type":21,"tag":68,"props":439,"children":440},{},[441,443,449],{"type":26,"value":442},"Run ",{"type":21,"tag":122,"props":444,"children":446},{"className":445},[],[447],{"type":26,"value":448},"nuget push yourfile.nupkg",{"type":26,"value":450}," again this time without the -source option to publish to the default public repository",{"type":21,"tag":22,"props":452,"children":453},{},[454],{"type":21,"tag":358,"props":455,"children":456},{},[457],{"type":26,"value":458},"[)amien",{"type":21,"tag":460,"props":461,"children":462},"style",{},[463],{"type":26,"value":464},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":181,"searchDepth":466,"depth":466,"links":467},2,[468,472,473,474,475],{"id":55,"depth":466,"text":58,"children":469},[470],{"id":105,"depth":471,"text":87},3,{"id":149,"depth":466,"text":152},{"id":294,"depth":466,"text":297},{"id":318,"depth":466,"text":321},{"id":384,"depth":466,"text":387},"markdown","content:blog:2014:simple-steps-for-publishing-your-nuget-package.md","content","blog/2014/simple-steps-for-publishing-your-nuget-package.md","blog/2014/simple-steps-for-publishing-your-nuget-package","md","/blog/2014/simple-steps-for-publishing-your-nuget-package/",639,[485,489,493],{"title":486,"date":487,"url":488},"HTML5 Video Cheatsheet: Optimizing videos for the web","2025-12-05T00:00:00Z","/blog/2025/html5-video-cheatsheet/",{"title":490,"date":491,"url":492},"Transactions in the MongoDB EF Core Provider","2025-10-25","/blog/2025/mongodb-explicit-transactions/",{"title":494,"date":495,"url":496},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","/blog/2025/mongodb-queryable-encryption/",[498],{"_path":499,"_dir":500,"_draft":6,"_partial":6,"_locale":7,"title":501,"description":502,"id":503,"name":504,"email":505,"avatar":506,"date":507,"body":508,"_type":476,"_id":553,"_source":478,"_file":554,"_stem":555,"_extension":481},"/comments/simple-steps-for-publishing-your-nuget-package/76775","simple-steps-for-publishing-your-nuget-package","76775","With nuget.exe v2.8.50126.400, in \"4. Test your package\", your step 2 gives \"unknown command 'publish'\"",76775,"Jason","jharrop@gmail.com","https://www.gravatar.com/avatar/64acd91faa1a8a27569f491a53c3b469?r=pg&d=retro","2014-02-26T22:23:13",{"type":18,"children":509,"toc":551},[510,514,519,547],{"type":21,"tag":22,"props":511,"children":512},{},[513],{"type":26,"value":502},{"type":21,"tag":22,"props":515,"children":516},{},[517],{"type":26,"value":518},"The following worked for me:",{"type":21,"tag":177,"props":520,"children":524},{"className":521,"code":522,"language":523,"meta":181,"style":181},"language-powershell shiki shiki-themes everforest-light dracula","nuget push yourfile.nupkg -source c:\\\\testnuget\n","powershell",[525],{"type":21,"tag":122,"props":526,"children":527},{"__ignoreMap":181},[528],{"type":21,"tag":188,"props":529,"children":530},{"class":190,"line":191},[531,537,542],{"type":21,"tag":188,"props":532,"children":534},{"style":533},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[535],{"type":26,"value":536},"nuget push yourfile.nupkg ",{"type":21,"tag":188,"props":538,"children":539},{"style":201},[540],{"type":26,"value":541},"-",{"type":21,"tag":188,"props":543,"children":544},{"style":533},[545],{"type":26,"value":546},"source c:\\\\testnuget\n",{"type":21,"tag":460,"props":548,"children":549},{},[550],{"type":26,"value":464},{"title":181,"searchDepth":466,"depth":466,"links":552},[],"content:comments:simple-steps-for-publishing-your-nuget-package:76775.md","comments/simple-steps-for-publishing-your-nuget-package/76775.md","comments/simple-steps-for-publishing-your-nuget-package/76775",1779264583176]