{"id":229040,"date":"2020-04-22T12:06:50","date_gmt":"2020-04-22T19:06:50","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=229040"},"modified":"2022-06-09T11:35:55","modified_gmt":"2022-06-09T18:35:55","slug":"creating-and-packaging-net-standard-library","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/creating-and-packaging-net-standard-library\/","title":{"rendered":"Creating and Packaging a .NET Standard library"},"content":{"rendered":"<p>In this post we will cover how you can create a .NET Standard library and then share that with other developers via NuGet. We will be demonstrating this with <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/mac\/\">Visual Studio for Mac<\/a>, but you can also follow along with Visual Studio, or Visual Studio Code when using the dotnet CLI. If you are on macOS, and haven\u2019t already download Visual Studio for Mac you can <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/mac\/\">download it here<\/a>. We will create a new .NET Standard library from scratch, configure it for NuGet and then publish to <a href=\"https:\/\/www.nuget.org\/\">nuget.org<\/a>. The sample library will be a logging package.<\/p>\n<p>When developing your applications, it is common to create some code that you\u2019d like to share with other applications. In cases where the consuming code is near the library code (e.g. in the same repo) you can share the project with a <a href=\"https:\/\/docs.microsoft.com\/visualstudio\/mac\/managing-references-in-a-project?view=vsmac-2019\">Project Reference<\/a>. In cases where the consuming code is not near the library or a different team\/org needs to consume it, a Project Reference may not be the correct choice. In these cases you can package your library as a NuGet package and then share it using that.<\/p>\n<p>When using NuGet there are different models of how you can share that NuGet package. You can share the library at <a href=\"https:\/\/www.nuget.org\/\">nuget.org<\/a> to the entire community or you can <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/hosting-packages\/overview\">create your own NuGet feed<\/a> so that you can have better control over who has access to your library. For this post we will be using <a href=\"https:\/\/www.nuget.org\/\">nuget.org<\/a>. Most of the content of this post will be relevant no matter how you decided to distribute the package. Let\u2019s get started on creating a sample library project.<\/p>\n<h2>Create the shared library project and add some code<\/h2>\n<p>The first thing you\u2019ll do when creating a library is to create a library project that will contain the code. In Visual Studio for Mac you can create a new .NET library project. To do this, after launching Visual Studio for Mac you should see the dialog below, click New to get started.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229041\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/01-vsmac-get-to-code.png\" alt=\"vsmac start screen\" width=\"720\" height=\"441\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/01-vsmac-get-to-code.png 720w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/01-vsmac-get-to-code-300x184.png 300w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>This will launch the New Project Dialog, shown below. On the left hand side select .NET Core &gt; Library.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229042\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/02-vsmac-new-project-netcore-library.png\" alt=\"vsmac new project dialog\" width=\"901\" height=\"654\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/02-vsmac-new-project-netcore-library.png 901w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/02-vsmac-new-project-netcore-library-300x218.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/02-vsmac-new-project-netcore-library-768x557.png 768w\" sizes=\"(max-width: 901px) 100vw, 901px\" \/><\/p>\n<p><em>Note: the .NET Core node on the left-hand side of the New Project Dialog is changing to Web and Cloud and will be moved to the top of the list in the next release. <\/em><\/p>\n<p>From here you\u2019ll select the .NET Standard template.<\/p>\n<blockquote><p>A .NET Standard Library is a class library that targets <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/net-standard\">.NET Standard<\/a>. .NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations. The motivation behind .NET Standard is to establish greater uniformity in the .NET ecosystem.<\/p><\/blockquote>\n<p>Click Next to proceed. You\u2019ll be prompted to select the Target Framework. After selecting a Target Framework, or going with the default, click Next. You\u2019ll then be prompted to provide a name and location for the project. In this example I specified <em>SayedHa.Log<\/em> as the name of the project to create. Click Create after you have supplied those values. When the project, and solution, are created you\u2019ll see the IDE editor open. It should look like the following image.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229045\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/03-vsmac-sayedhalog-newproject-created.png\" alt=\"vsmac with a .net std library project\" width=\"800\" height=\"578\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/03-vsmac-sayedhalog-newproject-created.png 800w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/03-vsmac-sayedhalog-newproject-created-300x217.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/03-vsmac-sayedhalog-newproject-created-768x555.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>The template will create a class named Class1. You can either rename this file, or simply delete and add a new class with the correct name. I\u2019ll take the latter approach.<\/p>\n<p>To add the new class, right click on the project and select Add &gt; Add Class, give the class the name <em>Logger<\/em>. You can also use Add &gt; Add File, but you\u2019ll need to select the Empty Class template. Add &gt; Add Class is a shortcut with that template pre-selected. Now we need to add some code to this logger class.<\/p>\n<p>Since this is just an example, the Logger class is going to be very basic. The code for it is below.<\/p>\n<pre class=\"prettyprint\">using System;\r\nusing System.Net.Security;\r\n\r\nnamespace SayedHa.Log {\r\n    public class Logger {\r\n        private Logger() { }\r\n        public void Debug(object message) { LogIt(\"Debug\", message, null); }\r\n        public void Debug(object message, Exception ex) { LogIt(\"Debug\", message, ex); }\r\n\r\n        public void Info(object message) { LogIt(\"Info\", message, null); }\r\n        public void Info(object message, Exception ex) { LogIt(\"Info\", message, ex); }\r\n\r\n        public void Error(object message) { LogIt(\"Error\", message, null); }\r\n        public void Error(object message, Exception ex) { LogIt(\"Error\", message, ex); }\r\n\r\n        public void Fatal(object message) { LogIt(\"Fatal\", message, null); }\r\n        public void Fatal(object message, Exception ex) { LogIt(\"Fatal\", message, ex); }\r\n\r\n        public void Verbose(object message) { LogIt(\"Verbose\", message, null); }\r\n        public void Verbose(object message, Exception ex) { LogIt(\"Verbose\", message, ex); }\r\n\r\n        protected void LogIt(string prefix, object message, Exception ex) {\r\n            string formatstr = ex == null ? \"{0}:\\t{1}\" : \"{0}:\\t{1}\\tException:{2}\";\r\n\r\n            Console.WriteLine(string.Format(formatstr, prefix, message, ex));\r\n        }\r\n\r\n        public static Logger GetNewLogger() {\r\n            return new Logger();\r\n        }\r\n    }\r\n}<\/pre>\n<p>We have now created the Logger class with the methods that we would like to support. Since we are going to distribute this and it will be used by a variety of apps we should create an interface for this so that we can have more flexibility in the future. To create an interface from this class we can use the Extract Interface feature in Visual Studio for Mac. Put your cursor on the name of the class and then right click and select Quick Fix. See below.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229047\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/04-vsmac-quick-fix.png\" alt=\"vsmac quick fix\" width=\"725\" height=\"460\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/04-vsmac-quick-fix.png 725w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/04-vsmac-quick-fix-300x190.png 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/p>\n<p>After selecting Quick Fix on the class you\u2019ll be prompted to select the quick fix you\u2019d like to apply. \u00a0In this case we will use <em>Extract Interface<\/em>.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229048\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/05-vsmac-extract-interface.png\" alt=\"vsmac extract interface\" width=\"544\" height=\"365\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/05-vsmac-extract-interface.png 544w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/05-vsmac-extract-interface-300x201.png 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/p>\n<p>After selecting <em>Extract Interface<\/em> a dialog will appear in which you can name the new interface and which methods should be included. By default all methods and properties will be included in the interface, and the proposed name of the interface will be the name of your class prefixed with \u201cI\u201d. For this case we will go with the defaults.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229050\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/06-vsmac-extract-interface-dialog.png\" alt=\"vsmac extract interface dialog\" width=\"400\" height=\"443\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/06-vsmac-extract-interface-dialog.png 400w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/06-vsmac-extract-interface-dialog-271x300.png 271w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>Now the interface has been generated, added to the project and the Logger class has been modified to implement that interface. One additional change that I made to the Logger class was to modify the GetLogger static method to return ILogger instead of Logger. We are done with the code portion, so let\u2019s move on to configure this as a NuGet package.<\/p>\n<h2>Adding properties to support packing<\/h2>\n<p>Creating a NuGet package from a .NET Standard Library project is very easy. We will use Pack to create a package from this. You could do this now, but it\u2019s best to add some metadata to the project before distributing it. These properties will be shown in nuget.org, and other NuGet servers. We will add some properties to the project file, the .csproj file. To get started, right click on the project and select <em>Edit Project File<\/em>.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229051\" style=\"font-size: 1rem;\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/07-vsmac-edit-proj-file.png\" alt=\"Image 07 vsmac edit proj file\" width=\"351\" height=\"590\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/07-vsmac-edit-proj-file.png 351w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/07-vsmac-edit-proj-file-178x300.png 178w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/><\/p>\n<p><em>Note: in previous versions of Visual Studio for Mac Edit Project File was nested under Tools in the project context menu.<\/em><\/p>\n<p>This will open up the project file for editing. We will add several properties to this file. The final result is shown in the snippet that follows, we will explain the properties after the code.<\/p>\n<pre class=\"prettyprint\">&lt;Project Sdk=\"Microsoft.NET.Sdk\"&gt;\r\n\r\n  &lt;PropertyGroup&gt;\r\n    &lt;TargetFramework&gt;netstandard2.0&lt;\/TargetFramework&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n  \r\n &lt;PropertyGroup&gt;\r\n    &lt;!-- where should the nuget package be created at --&gt;\r\n    &lt;PackageOutputPath&gt;.\/nupkg&lt;\/PackageOutputPath&gt;\r\n    \r\n    &lt;!-- nuget related properties --&gt;\r\n    &lt;Authors&gt;Sayed Ibrahim Hashimi&lt;\/Authors&gt;\r\n    &lt;Description&gt;Sample library showing how to create a .NET library.&lt;\/Description&gt;\r\n    &lt;Version&gt;1.0.0&lt;\/Version&gt;\r\n    &lt;Copyright&gt;Copyright 2020 \u00a9 Sayed Ibrahim Hashimi. All rights reserved.&lt;\/Copyright&gt;\r\n    &lt;PackageLicenseExpression&gt;Apache-2.0&lt;\/PackageLicenseExpression&gt;\r\n    &lt;RepositoryUrl&gt;https:\/\/github.com\/sayedihashimi\/sayedha.samplelibrary&lt;\/RepositoryUrl&gt;\r\n    &lt;RepositoryType&gt;git&lt;\/RepositoryType&gt;\r\n    &lt;PackageIconUrl&gt;https:\/\/raw.githubusercontent.com\/sayedihashimi\/sayedha.samplelibrary\/master\/assets\/icon-120x120.png&lt;\/PackageIconUrl&gt;\r\n    &lt;PackageIcon&gt;icon-120x120.png&lt;\/PackageIcon&gt;\r\n  &lt;\/PropertyGroup&gt;\r\n  &lt;ItemGroup&gt;\r\n    &lt;None Include=\"icon-120x120.png\" Pack=\"true\" PackagePath=\"\\\"\/&gt;\r\n  &lt;\/ItemGroup&gt;\r\n&lt;\/Project&gt;<\/pre>\n<p>These are the properties that I typically set when creating a NuGet package. Descriptions for the properties that I used are below. You can see the full list of NuGet related properties that can be set over at <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/csproj#nuget-metadata-properties\">NuGet metadata properties<\/a>.<\/p>\n<table style=\"width: 64.944%; height: 719px;\">\n<tbody>\n<tr>\n<td width=\"312\"><strong>Property name<\/strong><\/td>\n<td width=\"312\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"312\">PackageOutputPath<\/td>\n<td width=\"312\">Path to where the .nupkg file should be placed.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">Authors<\/td>\n<td width=\"312\">Name of the author(s) of the project.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">Description<\/td>\n<td width=\"312\">Description that will be shown in nuget.org and other places.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">Version<\/td>\n<td width=\"312\">Version of the NuGet package. For each release to nuget.org this must be unique.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">Copyright<\/td>\n<td width=\"312\">Copyright declaration.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">PackageLicenseExpression<\/td>\n<td width=\"312\">An <a href=\"https:\/\/spdx.org\/licenses\/\">SPDX license identifier<\/a> or expression.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">RepositoryUrl<\/td>\n<td width=\"312\">Specifies the URL for the repository where the source code for the package resides and\/or from which it&#8217;s being built.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">RepositoryType<\/td>\n<td width=\"312\">Repository type. Examples: git, tfs.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">PackageIconUrl<\/td>\n<td width=\"312\">URL for the package icon. This property is being deprecated in favor for PackageIcon. For now it is advised to declare both properties for maximum compatibility, see \u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/reference\/msbuild-targets#packageicon\">this doc<\/a>.<\/td>\n<\/tr>\n<tr>\n<td width=\"312\">PackageIcon<\/td>\n<td width=\"312\">Icon to be shown for the package.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In addition to these properties we also have an item for the Icon.<\/p>\n<p>After adding this content to your project, you can save and close that file. We are now ready to package this an upload it to <a href=\"https:\/\/www.nuget.org\/\">nuget.org<\/a>.<\/p>\n<p>To create the NuGet package, right click on the project in the Solution and select Pack. This will pack your project and put it in the folder specified in the PackageOutputPath property. If you did not set this property, the .nupkg file will be located in a folder under the bin folder. If you are following along using the dotnet CLI execute the <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-pack\">dotnet pack<\/a> command to create the NuGet package.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229063\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/07b2-vsmac-pack-command.png\" alt=\"vsmac pack command\" width=\"495\" height=\"488\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/07b2-vsmac-pack-command.png 495w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/07b2-vsmac-pack-command-300x296.png 300w\" sizes=\"(max-width: 495px) 100vw, 495px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Publish to nuget.org<\/h2>\n<p>Now we are ready to publish this to nuget.org. We will briefly go over that here, but for more details you can read more in the docs at <a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/nuget-org\/publish-a-package\">Publishing packages<\/a>. To publish a package to nuget.org, you\u2019ll need to create and account and sign in. After signing in, click on your profile on the top right and select Upload Package.<\/p>\n<p>Yes, Visual Studio for Mac uses the &#8220;Pad&#8221; term for the equivalent of what Visual Studio (Windows) calls &#8220;Tool Windows&#8221;. There&#8217;s discussion about changing that term to align with Windows, but it&#8217;s the correct term at this point.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229052\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/08-nuget-upload.png\" alt=\"nuget upload\" width=\"392\" height=\"452\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/08-nuget-upload.png 392w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/08-nuget-upload-260x300.png 260w\" sizes=\"(max-width: 392px) 100vw, 392px\" \/><\/p>\n<p>You\u2019ll be prompted to upload the .nupkg file. You can find this file in the nupkg folder under the project. If you have customized the PackageOutputPath project property different from the sample, then the file will be located at the path you specified. After you upload the package, the metadata will be presented. It\u2019s good to carefully verify that there are no errors because you cannot change a package version which has been published. After verifying the info, scroll down to the bottom of the package and click Submit.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229053\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/09-nuget-submit.png\" alt=\"nuget submit\" width=\"2048\" height=\"577\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/09-nuget-submit.png 2048w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/09-nuget-submit-300x84.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/09-nuget-submit-1024x288.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/09-nuget-submit-768x216.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/09-nuget-submit-1536x432.png 1536w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/p>\n<p>Your package has now been published to NuGet. After a few minutes your package will be index and ready to . Now that it has been published users can add this package to their projects to develop against the API. In Visual Studio for Mac, to add a NuGet package first right click the project in the Solution Pad and select <em>Manage NuGet Packages<\/em>. This will open a dialog that can be used to search and install packages. See the following image.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229054\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/10-vsmac-add-nuget-package.png\" alt=\"vsmac add nuget package\" width=\"840\" height=\"550\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/10-vsmac-add-nuget-package.png 840w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/10-vsmac-add-nuget-package-300x196.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/10-vsmac-add-nuget-package-768x503.png 768w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/p>\n<p>In this search box on the top right search for the package, sayedha.log in this case, then check the checkbox next to the package to install and finally click <em>Add Package<\/em>. When using Visual Studio the process is similar but with a different UX. When using the command line you can use <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/dotnet-add-package\">dotnet add package<\/a>. In the image below you\u2019ll find some sample code of using the package and the output when running the it.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-229059\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/11-vsmac-sample-app.png\" alt=\"vsmac sample app\" width=\"1077\" height=\"668\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/11-vsmac-sample-app.png 1077w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/11-vsmac-sample-app-300x186.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/11-vsmac-sample-app-1024x635.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2020\/04\/11-vsmac-sample-app-768x476.png 768w\" sizes=\"(max-width: 1077px) 100vw, 1077px\" \/><\/p>\n<h2>Summary and wrap up<\/h2>\n<p>In this post we have created a simple .NET Standard library, modified it to be a NuGet package and published it to <a href=\"https:\/\/www.nuget.org\/\">nuget.org<\/a>. This was a very basic library, when creating more realistic libraries there may be additional things to consider. For example, if you want to support multiple frameworks you will need to make some changes. For more details on that see <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/library-guidance\/cross-platform-targeting\">Cross-platform targeting<\/a> for how to get started with that.<\/p>\n<p>Make sure to follow us on Twitter at\u00a0<a href=\"https:\/\/twitter.com\/VisualStudioMac\">@VisualStudioMac<\/a>\u00a0and reach out to the team. Customer feedback is important to us and we would love to hear your thoughts. Alternatively, you can head over to\u00a0<a href=\"https:\/\/aka.ms\/feedback\/vsm-home\">Visual Studio Developer Community<\/a>\u00a0to track your issues,\u00a0<a href=\"https:\/\/aka.ms\/vsmac-suggestion\">suggest a feature<\/a>, ask questions, and find answers from others. We use your feedback to continue to improve Visual Studio 2019 for Mac, so thank you again on behalf of our entire team.<\/p>\n<h2>Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/visualstudio.microsoft.com\/vs\/mac\/\">Download Visual Studio for Mac<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/sayedihashimi\/sayedha.samplelibrary\">Code for this sample<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/hosting-packages\/overview\">Hosting your own NuGet feeds<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/nuget\/nuget-org\/publish-a-package\">Publishing NuGet packages<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/library-guidance\/cross-platform-targeting\">Cross-platform targeting<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In this post we will cover how you can create a .NET Standard library and then share that with other developers via NuGet. We will be demonstrating this with Visual Studio for Mac, but you can also follow along with Visual Studio, or Visual Studio Code when using the dotnet CLI. If you are on [&hellip;]<\/p>\n","protected":false},"author":357,"featured_media":229063,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[3743,452],"class_list":["post-229040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-visual-studio-2019-for-mac","tag-visual-studio-for-mac"],"acf":[],"blog_post_summary":"<p>In this post we will cover how you can create a .NET Standard library and then share that with other developers via NuGet. We will be demonstrating this with Visual Studio for Mac, but you can also follow along with Visual Studio, or Visual Studio Code when using the dotnet CLI. If you are on [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/229040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/357"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=229040"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/229040\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/229063"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=229040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=229040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=229040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}