﻿{"id":443,"date":"2018-09-26T20:48:31","date_gmt":"2018-09-26T18:48:31","guid":{"rendered":"https:\/\/blog.pjsen.eu\/?p=443"},"modified":"2022-02-22T13:54:48","modified_gmt":"2022-02-22T12:54:48","slug":"a-few-random-asp-net-core-and-net-core-tips","status":"publish","type":"post","link":"https:\/\/blog.pjsen.eu\/?p=443","title":{"rendered":"A few random ASP.NET Core and .NET Core tips"},"content":{"rendered":"<p>I&#8217;ve been working with .NET core recently and I&#8217;d like to post some random observations on this subject for the future reference.<\/p>\n<ol>\n<li>\nIt is possible to create Nuget package upon build. This option is actually available also from the VS2017 Project properties GUI. Add this code to <code>csproj<\/code>.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/przemsen\/97eaf5028e91b9111fae417055eb9c3e.js?file=blog-2018-09-26-xml1.xml\"><\/script><\/p>\n<\/li>\n<li>\nIt is possible to add local folder as Nuget feed. The folder can also be current user&#8217;s profile. This one is actually not Core specific. <code>Nuget.config<\/code> should look like this:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/przemsen\/97eaf5028e91b9111fae417055eb9c3e.js?file=blog-2018-09-26-xml2.xml\"><\/script><\/p>\n<\/li>\n<li>\nYou can compile for multiple targets in <code>.NET Core<\/code> compatible <code>csproj<\/code>. Please note the trailing <span style='color:red'><strong>s<\/strong><\/span> in the tag name. You can also conditionally include items in <code>csproj<\/code>. Use the following snippets: <\/p>\n<p><script src=\"https:\/\/gist.github.com\/przemsen\/97eaf5028e91b9111fae417055eb9c3e.js?file=blog-2018-09-26-xml3.xml\"><\/script><\/p>\n<p>and:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/przemsen\/97eaf5028e91b9111fae417055eb9c3e.js?file=blog-2018-09-26-xml4.xml\"><\/script><\/p>\n<p>There is a reference documentation for the available targets: <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/frameworks\">here<\/a>.<\/p>\n<\/li>\n<li>\nThe listening port in Kestrel can be configured in multiple ways. It can be read from environment variable or can be passed as command line argument. An asterisk is required to bind to physical interfaces. It is needed e.g. when trying to display the application from mobile phone when being served from development machine. The following are equivalent:<\/p>\n<pre>\r\nset ASPNETCORE_URLS=http:\/\/*:11399\r\n--urls http:\/\/*:11399\r\n<\/pre>\n<\/li>\n<li>\nThe preferred way to pass hosting parameters to Kestrel is <code>launchSettings.json<\/code> file located in <code>Properties<\/code> of the solution root. You can select a profile defined there when running:<\/p>\n<pre>\r\ndotnet run --launch-profile \"Dev\"\r\n<\/pre>\n<p><code>dotnet run<\/code> is used to build and run from the directory where <code>csproj<\/code> resides. It is not a good idea to run the app&#8217;s dll directly. Settings file can be missing from <code>bin<\/code> folder and\/or launch profile may not be present there.<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working with .NET core recently and I&#8217;d like to post some random observations on this subject for the future reference. It is possible to create Nuget package upon build. This option is actually available also from the VS2017 Project properties GUI. Add this code to csproj. It is possible to add local folder<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,7],"tags":[],"class_list":["post-443","post","type-post","status-publish","format-standard","hentry","category-net","category-asp-net","category-quick-tip"],"_links":{"self":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/posts\/443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=443"}],"version-history":[{"count":0,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/posts\/443\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}