<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://codeclimber.net.nz/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>CodeClimber</title>
    <link>http://codeclimber.net.nz/</link>
    <description>Climbing the cliffs of web development, on .NET</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <item>
      <guid isPermaLink="false">3419</guid>
      <link>http://codeclimber.net.nz/archive/2020/03/12/how-to-uninstall-old-versions-of-net-core/</link>
      <title>How to uninstall old versions of .NET Core</title>
      <description>&lt;p&gt;Uninstalling old versions of .NET Core used to be a tedious process, so much that I had 1.0 and previews of 2.0 still installed.&lt;/p&gt;
&lt;p&gt;But now it's super easy thanks to the newly released &lt;a href="https://devblogs.microsoft.com/dotnet/announcing-the-net-core-uninstall-tool-1-0/"&gt;.NET Core Uninstall Tool&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Just &lt;a href="https://github.com/dotnet/cli-lab/releases"&gt;install the tool&lt;/a&gt;, and launch the following command to remove all that is not needed.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo ./dotnet-core-uninstall remove --runtime --all
sudo ./dotnet-core-uninstall remove --sdk --all
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But if you want to understand more, please keep on reading.&lt;/p&gt;
&lt;h3&gt;See which version you have installed&lt;/h3&gt;
&lt;p&gt;If you run the following command on your terminal you can see all the runtimes and SDKs installed on your machine:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;dotnet --list-sdks
dotnet --list-runtimes
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On my Mac I have 10 SDKs &lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1080/netcore-sdks-before-compressor.png?width=800" alt=".NET Core SDKs" /&gt;&lt;/p&gt;
&lt;p&gt;and 8 versions of the ASP.NET Core runtime and 13 versions of the NETCore runtime.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1079/netcore-runtimes-before-compressor.png?width=800" alt=".NET Core runtimes" /&gt;&lt;/p&gt;
&lt;p&gt;If you wanted to get rid of the old version, you had to go and manually delete the content of the folders on Mac and via the &amp;quot;Add or Remove Programs&amp;quot; on Windows.&lt;/p&gt;
&lt;p&gt;But now you can have a tool to do it for you, the &lt;a href="https://docs.microsoft.com/en-us/dotnet/core/additional-tools/uninstall-tool"&gt;.NET Core Uninstall Tool&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;The .NET Core Uninstall Tool&lt;/h3&gt;
&lt;p&gt;After you &lt;a href="https://github.com/dotnet/cli-lab/releases"&gt;installed it&lt;/a&gt;, there are a few commands you can run:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;list&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;dry-run&lt;/code&gt; (or &lt;code&gt;whatif&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;remove&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;The list command&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;list&lt;/code&gt; command shows all the SDKs and runtimes you have installed. You can use the options &lt;code&gt;--sdk&lt;/code&gt; or &lt;code&gt;--runtime&lt;/code&gt; to just show either the SDKs or the runtimes. Or &lt;code&gt;--x64&lt;/code&gt; or &lt;code&gt;--x86&lt;/code&gt; to filter based on the architecture. &lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1087/uninstall-list-compressor.png?width=800" alt="list all" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, some runtimes and on SDK are marked as not safe to remove.&lt;/p&gt;
&lt;h4&gt;The dry-run command&lt;/h4&gt;
&lt;p&gt;If you have multiple version installed, you probably don't want to delete them individually. The uninstall tool has a series of options to do a bulk delete. But before you delete everything by mistake, you might want to see what each option does. And here comes the &lt;code&gt;dry-run&lt;/code&gt; command, which lists the versions that would be deleted by the &lt;code&gt;remove&lt;/code&gt; command when called with the same options. Here some examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--all&lt;/code&gt; will delete everything&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1083/uninstall-dry-run-all-compressor.png?width=800" alt="--all" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--all-below &amp;lt;version&amp;gt;&lt;/code&gt;, deletes all versions below the one specified&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1081/uninstall-dry-run-all-below-compressor.png?width=800" alt="--all-below" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--all-but &amp;lt;versions&amp;gt;&lt;/code&gt;, deletes everything but the specified versions&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--all-lower-patches&lt;/code&gt;, deletes all versions for which there is a higher patch&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1084/uninstall-dry-run-all-lower-compressor.png?width=800" alt="--all-lower-patches" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--all-previews&lt;/code&gt;, deletes all preview versions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1085/uninstall-dry-run-all-preview-compressor.png?width=800" alt="--all-previews" /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--all-previews-but-latest&lt;/code&gt;, just keeps the more recent preview (useful when testing pre-releases)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--major-minor &amp;lt;major.minor&amp;gt;&lt;/code&gt;, deletes all the version of the specified &lt;code&gt;major.minor&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notice that in none of the examples, the versions listed as &amp;quot;not safe&amp;quot; are not appearing. This because if you remove them you might break some functionality. To include them, add the &lt;code&gt;--force&lt;/code&gt; option. But don't worry, you'll get a nice red message to warn you.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1082/uninstall-dry-run-all-below-force-compressor.png?width=800" alt="--all-below-force" /&gt;&lt;/p&gt;
&lt;h4&gt;The Remove command&lt;/h4&gt;
&lt;p&gt;Once you've found the parameters to delete the right versions, you can use them with the &lt;code&gt;remove&lt;/code&gt; command, to actually delete the versions. The only difference is that you need to run the tool with elevated rights (as Administrator on Windows or via &lt;code&gt;sudo&lt;/code&gt; on Mac), and that there is a &lt;code&gt;--yes&lt;/code&gt; option to skip the confirmation.&lt;/p&gt;
&lt;p&gt;Normally, unless you want to start a new application in an older version, you can delete everything except the latest SDK and runtimes. If you want to be sure you don't cause any problem, the safest commands are:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./dotnet-core-uninstall remove --runtime --all
./dotnet-core-uninstall remove --sdk --all
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These will uninstall everything that is not needed by Visual Studio.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1086/uninstall-list-after-compressor.png?width=800" alt="list all after uninstall" /&gt;&lt;/p&gt;
&lt;p&gt;If you know you are not going to build new projects with older runtimes, you can also just run &lt;code&gt;remove --runtime --all-but 3.1.1 --force&lt;/code&gt; to just keep the latest version.&lt;/p&gt;
</description>
      <pubDate>Thu, 12 Mar 2020 22:00:26 Z</pubDate>
      <a10:updated>2020-03-12T22:00:26Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3412</guid>
      <link>http://codeclimber.net.nz/archive/2019/07/15/7-easy-steps-to-install-miniprofiler-on-an-aspnet-mvc-website/</link>
      <title>7 easy steps to install MiniProfiler on an ASP.NET MVC website</title>
      <description>&lt;p&gt;Today I wanted to add &lt;a href="https://miniprofiler.com/dotnet/"&gt;MiniProfiler&lt;/a&gt; to an ASP.NET MVC web application (not .NET Core), but unfortunately &lt;a href="https://www.nuget.org/packages/MiniProfiler.Mvc5/"&gt;the NuGet package&lt;/a&gt; doesn't set up things correctly, the &lt;a href="https://miniprofiler.com/dotnet/AspDotNet"&gt;documentation&lt;/a&gt; is a bit lacking, and &lt;a href="https://github.com/MiniProfiler/dotnet/tree/master/samples/Samples.Mvc5"&gt;their sample project&lt;/a&gt; doesn't work. What was supposedly a simple task, took almost a full day of research to make it work.&lt;/p&gt;
&lt;p&gt;In this post, I'm going to explain in 7 easy steps how to install &lt;a href="https://miniprofiler.com/dotnet/"&gt;MiniProfiler&lt;/a&gt; on an empty ASP.NET MVC web application.&lt;/p&gt;
&lt;h3&gt;Step 1 - Create an ASP.NET MVC application&lt;/h3&gt;
&lt;p&gt;To keep things easy, let's start with creating a new ASP.NET MVC application. &lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1077/new-project.png" alt="Choose ASP.NET Web Application Project " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1073/choose-template.png" alt="Choose the MVC template" /&gt;&lt;/p&gt;
&lt;h3&gt;Step 2 - Install the MiniProfiler.MVC5 Nuget package&lt;/h3&gt;
&lt;p&gt;The correct NuGet package to install is &lt;code&gt;MiniProfiler.MVC5&lt;/code&gt;, which supplies the core &lt;code&gt;MiniProfiler&lt;/code&gt; package and provides the correct integration with ASP.NET MVC.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Install-Package MiniProfiler.Mvc5
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 3 - Add the minimum MiniProfiler configuration&lt;/h3&gt;
&lt;p&gt;The configuration happens in the &lt;code&gt;Application_Start&lt;/code&gt;, &lt;code&gt;Application_BeginRequest&lt;/code&gt; and &lt;code&gt;Application_EndRequest&lt;/code&gt; inside the &lt;code&gt;Global.asax.cs&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Inside the &lt;code&gt;Application_Start&lt;/code&gt; you have to add the following line, to set up the default options.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;MiniProfiler.Configure(new MiniProfilerOptions());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Moreover, then add the &lt;code&gt;Application_BeginRequest&lt;/code&gt; and &lt;code&gt;Application_EndRequest&lt;/code&gt; methods to start and stop the tracking at each request.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;protected void Application_BeginRequest()
{
    MiniProfiler profiler = null;
    if (Request.IsLocal)
    {
        profiler = MiniProfiler.StartNew();
    }
}

protected void Application_EndRequest()
{
    MiniProfiler.Current?.Stop();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 4 - Include the scripts in the view&lt;/h3&gt;
&lt;p&gt;You now need to include the scripts in the views. The easiest way is to add them in &lt;code&gt;Shared/_Layout.cshtml&lt;/code&gt; master view.&lt;/p&gt;
&lt;p&gt;At the top, add the namespace &lt;code&gt;using&lt;/code&gt; declaration &lt;code&gt;@using StackExchange.Profiling;&lt;/code&gt; and at the bottom, just before the &lt;code&gt;&amp;lt;/body&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    @MiniProfiler.Current.RenderIncludes()
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 5 - Configure the site to route all requests as managed code&lt;/h3&gt;
&lt;p&gt;If you run the site now, nothing happens. The reason is that MiniProfiler relies on a JavaScript library rendered at the moment, and it is requested as &lt;code&gt;.js&lt;/code&gt;, so usually it wouldn't be executed as .NET request. So, you have to add the following line in the &lt;code&gt;web.config&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;system.webServer&amp;gt;
   &amp;lt;modules runAllManagedModulesForAllRequests=&amp;quot;true&amp;quot; /&amp;gt;
 &amp;lt;/system.webServer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Running now the website you get the MiniProfiler UI in the top left corner of the site, and by clicking you get the execution timings of the page.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1074/miniprofiler-ui-1.png" alt="Basic profiling information" /&gt;&lt;/p&gt;
&lt;h3&gt;Step 6 - Configure to track MVC Controller&lt;/h3&gt;
&lt;p&gt;The current view is not very useful, as it shows nothing, apart from overall execution. In an ASP.NET MVC application, you can start tracking a bit more information on the execution time of each action, by adding a new filter into the pipeline. Open the &lt;code&gt;FilterConfig.cs&lt;/code&gt; file (if you are following along with the basic template) and add this line to the  &lt;code&gt;RegisterGlobalFilters&lt;/code&gt; method&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;filters.Add(new ProfilingActionFilter());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, rerun the same site, and you'll also see the execution time of the controller.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1075/miniprofiler-ui-2.png" alt="Profiling Action and Controllers" /&gt;&lt;/p&gt;
&lt;h3&gt;Step 7 - Start using it&lt;/h3&gt;
&lt;p&gt;There is no real step 7... but it's cool to have 7 steps.&lt;/p&gt;
&lt;p&gt;Jokes aside, now that the basic configuration is working, you can head to the official documentation to see &lt;a href="https://miniprofiler.com/dotnet/HowTo/ProfileCode"&gt;how to start profiling&lt;/a&gt; portions of your code in a way that matters, usually done via the &lt;code&gt;Step&lt;/code&gt; and &lt;code&gt;CustomTiming&lt;/code&gt; methods.&lt;/p&gt;
&lt;p&gt;Here some sample code you could add to your actions to experiment a bit.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public ActionResult Index()
{
    var profiler = MiniProfiler.Current;
    using (profiler.Step(&amp;quot;Set page title&amp;quot;))
    {
        ViewBag.Title = &amp;quot;Home Page&amp;quot;;
    }

    using (profiler.Step(&amp;quot;Doing complex stuff&amp;quot;))
    {
        using (profiler.Step(&amp;quot;Step A&amp;quot;))
        {
            // simulate fetching a url
            using (profiler.CustomTiming(&amp;quot;http&amp;quot;, &amp;quot;GET http://google.com&amp;quot;))
            {
                Thread.Sleep(10);
            }
        }
        using (profiler.Step(&amp;quot;Step B&amp;quot;))
        {
            // simulate fetching a url
            using (profiler.CustomTiming(&amp;quot;http&amp;quot;, &amp;quot;GET http://stackoverflow.com&amp;quot;))
            {
                Thread.Sleep(20);
            }

            using (profiler.CustomTiming(&amp;quot;redis&amp;quot;, &amp;quot;SET \&amp;quot;mykey\&amp;quot; 10&amp;quot;))
            {
                Thread.Sleep(5);
            }
        }
    }

    // now something that loops
    for (int i = 0; i &amp;lt; 15; i++)
    {
        using (profiler.CustomTiming(&amp;quot;redis&amp;quot;, &amp;quot;SET \&amp;quot;mykey\&amp;quot; 10&amp;quot;))
        {
            Thread.Sleep(i);
        }
    }

    return View();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This code generates the trace shown in the following picture.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1076/miniprofiler-ui-3.png" alt="Warnings and categories" /&gt;&lt;/p&gt;
&lt;p&gt;You can notice some interesting information detected by MiniProfiler. It detected that the code is calling the same 15 times (the loop at the bottom of the action method) and how much of the time is spent in different categories of operations (in the example, &lt;code&gt;http&lt;/code&gt; and &lt;code&gt;redis&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;An additional feature to add would be tracking SQL statements with the EF6 integration.&lt;/p&gt;
&lt;h3&gt;A word of caution&lt;/h3&gt;
&lt;p&gt;Miniprofiler might affect negatively the performances of you application, so it's recommended that you run the profiling code only when &lt;code&gt;Request.IsLocal&lt;/code&gt; and in debug mode.&lt;/p&gt;
&lt;p&gt;Additionally, when the project is deployed in a production environment, you need to remove the line in the &lt;code&gt;web.config&lt;/code&gt; that sets &lt;code&gt;runAllManagedModulesForAllRequests&lt;/code&gt; to true. This line forces all requests to be treated by the .NET framework, even static files. And this will affect the performances of the site.&lt;/p&gt;
&lt;p&gt;If you don't want to deal with web.config transformations, you can also set the handler specifically for the path used by MiniProfiler (as Paul recommended in the comment below):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;handlers&amp;gt;
   &amp;lt;add name=&amp;quot;MiniProfiler&amp;quot; path=&amp;quot;mini-profiler-resources/*&amp;quot; verb=&amp;quot;*&amp;quot; type=&amp;quot;System.Web.Routing.UrlRoutingModule&amp;quot; resourcetype=&amp;quot;Unspecified&amp;quot; precondition=&amp;quot;integratedMode&amp;quot;/&amp;gt;
&amp;lt;/handlers&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

</description>
      <pubDate>Mon, 15 Jul 2019 17:01:40 Z</pubDate>
      <a10:updated>2019-07-15T17:01:40Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3405</guid>
      <link>http://codeclimber.net.nz/archive/2019/06/24/how-to-run-micro-benchmarking-with-benchmarkdotnet-bonus-post-from-the-ray-tracer-challenge-series/</link>
      <title>How to run micro-benchmarking with BenchmarkDotNet - Bonus post from The Ray Tracer Challenge series</title>
      <description>&lt;p&gt;In the context of my &lt;a href="http://codeclimber.net.nz/archive/2019/05/22/raytracer-challenge-netcore-intro/"&gt;Ray Tracer Challenge&lt;/a&gt;, I wanted to run some performance analysis on my basic operations and data structures. For this installed and used &lt;a href="https://benchmarkdotnet.org"&gt;BenchmarkDotNet&lt;/a&gt;, an OSS benchmarking tool used by Microsoft for performance testing the .NET Core runtime and class library.&lt;/p&gt;
&lt;p&gt;In this post, I'm going to share what I learned about this powerful tool.&lt;/p&gt;
&lt;h2&gt;How to install BenchmarkDotNet&lt;/h2&gt;
&lt;p&gt;BenchmarkDotNet is not an application you have to install. It is a .NET library. To install it, create a console application and install the NuGet package.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;dotnet new console
dotnet add package BenchmarkDotNet
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As simple as that.&lt;/p&gt;
&lt;h2&gt;Writing benchmarks&lt;/h2&gt;
&lt;p&gt;Now that you have the project, you need to create a class with the benchmarks you want to run, and finally, add one line to the &lt;code&gt;Main&lt;/code&gt; of the &lt;code&gt;Program&lt;/code&gt; to start the execution of the benchmarks.&lt;/p&gt;
&lt;p&gt;Here a simple example that shows how to test the &amp;quot;performances&amp;quot; of the &lt;code&gt;Sleep&lt;/code&gt; method.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;using System;
using System.Threading;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

namespace MyBench
{
    public class Sleeps
    {
        [Benchmark]
        public void Time50() =&amp;gt; Thread.Sleep(50);

        [Benchmark(Baseline = true)]
        public void Time100() =&amp;gt; Thread.Sleep(100);

        [Benchmark]
        public void Time150() =&amp;gt; Thread.Sleep(150);
    }

    class Program
    {
        static void Main(string[] args)
        {
            var summary = BenchmarkRunner.Run&amp;lt;Sleeps&amp;gt;();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Notice that every method has the &lt;code&gt;[Benchmark]&lt;/code&gt; attribute. &lt;/p&gt;
&lt;h2&gt;Running benchmarks&lt;/h2&gt;
&lt;p&gt;Now it's time to run the benchmarks. To do it, just run the console application: &lt;code&gt;dotnet run&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately here you encountered the first problem, indicated by a red line in the terminal: you cannot run a benchmark in debug mode.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Assembly MyBench which defines benchmarks is non-optimized Benchmark
was built without optimization enabled (most probably a DEBUG
configuration). Please, build it in RELEASE. If you want to debug the
benchmarks, please see
https://benchmarkdotnet.org/articles/guides/troubleshooting.html#debugging-benchmarks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Unless you want to run the benchmark in debug mode, you have to run it in release mode: &lt;code&gt;dotnet run -c Release&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At this point, you see either one or two more red messages in the terminal, but the execution goes on and complete successfully.&lt;/p&gt;
&lt;p&gt;The first complains that there is no solution file. Since you only created a project, this is normal. So skip over it.&lt;/p&gt;
&lt;p&gt;The second, which might not appear depending on the OS and permission of the users you logged in with, is also not affecting the success of the execution but might affect the results. &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Failed to set up high priority. Make sure you have the right
permissions. Message: Permission denied&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This message means that the benchmark runner was not able to set the execution to high CPU priority, so the benchmark will run slower, especially if other applications are running at the same time.&lt;/p&gt;
&lt;p&gt;If you encounter this problem, either run the command as Administrator on Windows or &lt;code&gt;sudo&lt;/code&gt; it if running on Mac or Linux.&lt;/p&gt;
&lt;p&gt;Having solved the two issues, the correct way of starting the benchmark is &lt;code&gt;sudo dotnet run -c Release&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Analysing the results&lt;/h2&gt;
&lt;p&gt;After a while (the example of this post took 45 seconds to complete), you get a summary with the mean execution time of all your benchmarks. By default, you get:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Markdown (Github dialect)&lt;/li&gt;
&lt;li&gt;HTML report&lt;/li&gt;
&lt;li&gt;CSV you can import in Excel for additional analysis&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As example this is what I got from my machine:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Method&lt;/th&gt;&lt;th&gt;Mean&lt;/th&gt;&lt;th&gt;Error&lt;/th&gt;&lt;th&gt;StdDev&lt;/th&gt;&lt;th&gt;Ratio&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Time50&lt;/td&gt;&lt;td&gt;52.28 ms&lt;/td&gt;&lt;td&gt;0.4682 ms&lt;/td&gt;&lt;td&gt;0.4380 ms&lt;/td&gt;&lt;td&gt;0.51&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Time100&lt;/td&gt;&lt;td&gt;101.99 ms&lt;/td&gt;&lt;td&gt;0.9778 ms&lt;/td&gt;&lt;td&gt;0.9146 ms&lt;/td&gt;&lt;td&gt;1.00&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Time150&lt;/td&gt;&lt;td&gt;151.74 ms&lt;/td&gt;&lt;td&gt;0.9426 ms&lt;/td&gt;&lt;td&gt;0.8817 ms&lt;/td&gt;&lt;td&gt;1.49&lt;/td&gt;
&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Usually, you'd get only the Mean, Error and StdDev columns, but since one of the benchmarks was marked as baseline (using the attribute &lt;code&gt;[Benchmark(Baseline = true)]&lt;/code&gt;), there is also the Ratio column, which tells you the relative difference in performances.&lt;/p&gt;
&lt;p&gt;BenchmarkDotNet can also generate plots with a summary of the results and with a detailed analysis of each execution. It relies on &lt;a href="https://www.r-project.org/"&gt;R&lt;/a&gt; (a statistical analysis framework) for the execution, so you'd need to install it. On Mac, it's as easy as &lt;code&gt;brew install r&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1067/5-barplot.png" alt="enter image description here" /&gt;
&lt;img src="http://codeclimber.net.nz/media/1069/5-boxplot.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;h2&gt;Additional features of BenchmarkDotNet&lt;/h2&gt;
&lt;p&gt;We just scratched the surface of BenchmarkDotNet. It has many more features that allow you to run benchmarks under different conditions.&lt;/p&gt;
&lt;h3&gt;Environments&lt;/h3&gt;
&lt;p&gt;You can, for example, ask to run the same benchmark on different frameworks, like .NET Core, Mono, x86 or x64 and then compare the results. This is configured via attributes, &lt;code&gt;[CoreJob, ClrJob, MonoJob]&lt;/code&gt;, or by providing a configuration object.&lt;/p&gt;
&lt;h3&gt;Parameters&lt;/h3&gt;
&lt;p&gt;Another interesting feature is the possibility of executing the same benchmarks with different parameters, for example, to see if a particular operation degrades when the number of iterations increases. This is also done with an attribute, [Params].&lt;/p&gt;
&lt;p&gt;For example, the same &lt;code&gt;Sleep&lt;/code&gt; test could have been done using parameters instead of creating three different benchmarks.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Sleeps
{
    [Params(50, 100, 150)]
    public int T { get; set; }

    [Benchmark]
    public void Sleep() =&amp;gt; Thread.Sleep(T);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The result is slightly different:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Method&lt;/th&gt;&lt;th&gt;T&lt;/th&gt;&lt;th&gt;Mean&lt;/th&gt;&lt;th&gt;Error&lt;/th&gt;&lt;th&gt;StdDev&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Sleep&lt;/td&gt;&lt;td&gt;50&lt;/td&gt;&lt;td&gt;52.09 ms&lt;/td&gt;&lt;td&gt;0.7825 ms&lt;/td&gt;&lt;td&gt;0.7319 ms&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Sleep&lt;/td&gt;&lt;td&gt;100&lt;/td&gt;&lt;td&gt;102.21 ms&lt;/td&gt;&lt;td&gt;1.2101 ms&lt;/td&gt;&lt;td&gt;1.1319 ms&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Sleep&lt;/td&gt;&lt;td&gt;150&lt;/td&gt;&lt;td&gt;152.25 ms&lt;/td&gt;&lt;td&gt;1.3064 ms&lt;/td&gt;&lt;td&gt;1.2220 ms&lt;/td&gt;
&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;This approach makes it also more comfortable to compare the results using the default plots generated with R, as some of the charts become more useful.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1066/5-barplot-params.png" alt="enter image description here" /&gt;
&lt;img src="http://codeclimber.net.nz/media/1068/5-boxplot-params.png" alt="enter image description here" /&gt;
&lt;img src="http://codeclimber.net.nz/media/1070/5-density-params.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;h2&gt;Running benchmarks&lt;/h2&gt;
&lt;p&gt;You have already seen the most straightforward way of running the benchmark by merely running the project.&lt;/p&gt;
&lt;p&gt;Unfortunately, this method is very limited.&lt;/p&gt;
&lt;h3&gt;Specifying console arguments&lt;/h3&gt;
&lt;p&gt;A better method is to change the &lt;code&gt;Main&lt;/code&gt; to use &lt;code&gt;BenchmarkSwitcher&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void Main(string[] args)
            =&amp;gt; BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This allows a lot of parameters to be passed to the benchmark execution. You can filter which benchmarks to run, change the runtimes on which to run, and specify other configurations parameters that otherwise had to be specified in code or with attributes directly in the benchmark.&lt;/p&gt;
&lt;h3&gt;Using the global dotnet tool&lt;/h3&gt;
&lt;p&gt;A final way of running benchmarks is via the global dotnet tool.&lt;/p&gt;
&lt;p&gt;You can install it via &lt;code&gt;dotnet tool install -g BenchmarkDotNet.Tool&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Once installed you can run a benchmark by specifying the name of the dll (&lt;code&gt;dotnet benchmark MyBench.dll&lt;/code&gt;), and then the same console arguments as with the &lt;code&gt;BenchmarkSwitcher&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;I hope I gave you a good overview of this fantastic tool. You can read more information on the official web site &lt;a href="https://benchmarkdotnet.org/articles/overview.html"&gt;https://benchmarkdotnet.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;While exploring this tool, I tried testing the performance of various ways of concatenating strings. Is &lt;code&gt;StringBuilder&lt;/code&gt; faster or slower than &lt;code&gt;String.Join&lt;/code&gt;? &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;Subscribe to my RSS feed&lt;/a&gt; or &lt;a href="https://twitter.com/simonech"&gt;follow me on Twitter&lt;/a&gt; to get notified when my analysis on this gets published.&lt;/p&gt;
</description>
      <pubDate>Mon, 24 Jun 2019 07:32:08 Z</pubDate>
      <a10:updated>2019-06-24T07:32:08Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3403</guid>
      <link>http://codeclimber.net.nz/archive/2019/06/21/free-ebook-on-aspnet-core-2-2-is-available-for-download/</link>
      <title>Free eBook on ASP.Net Core 2.2 is available for download</title>
      <description>&lt;p&gt;The eBook on ASP.NET Core 2 I wrote together with &lt;a href="http://tostring.it/"&gt;Ugo Lattanzi&lt;/a&gt; is available for &lt;a href="https://www.syncfusion.com/ebooks/aspnet-core-2-succinctly"&gt;download for free&lt;/a&gt; from the &lt;a href="https://www.syncfusion.com/resources/techportal/ebooks"&gt;Free Ebooks section of Syncfusion Tech Portal&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1065/d2vctqdw0aiu8th.jpg?width=600" alt="ASP.NET Core 2" /&gt;&lt;/p&gt;
&lt;p&gt;In April 2017, Ugo Lattanzi and I published &lt;a href="https://www.syncfusion.com/ebooks/asp_net_core_succinctly"&gt;ASP.NET Core Succinctly&lt;/a&gt;, and it became one of the most downloaded ebook for 2017 and was also &lt;a href="https://www.syncfusion.com/awards/succinctlyseries/2017succinctlyreadersawards"&gt;2017 Succinctly Readers Awards Silver Winner&lt;/a&gt;, among all the 33 books released by Succinctly in 2017.&lt;/p&gt;
&lt;p&gt;This year we published an update to the book. All code and explanation have been adapted and updated to cover version 2.2 of ASP.NET Core, and also we added features that were not available before like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Health Checks&lt;/li&gt;
&lt;li&gt;SPA templates&lt;/li&gt;
&lt;li&gt;Razor Pages&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, if you haven't already, go download the &lt;a href="https://www.syncfusion.com/ebooks/aspnet-core-2-succinctly"&gt;book&lt;/a&gt; and let us know what you think of it.&lt;/p&gt;
</description>
      <pubDate>Fri, 21 Jun 2019 13:53:33 Z</pubDate>
      <a10:updated>2019-06-21T13:53:33Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3400</guid>
      <link>http://codeclimber.net.nz/archive/2019/06/10/the-ray-tracer-challenge-drawing-to-a-canvas-and-saving-the-image-to-a-file/</link>
      <title>The Ray Tracer Challenge - Drawing to a canvas and saving the image to a file</title>
      <description>&lt;p&gt;In the previous post, I've shown how I implemented chapter 1 of the &lt;a href="https://amzn.to/2Elaxkr"&gt;Ray Tracing Challenge book&lt;/a&gt;, coding the basic primitives and their operations. And also implemented a ballistic trajectory calculator. In chapter 2, the goal is to be able to draw an image on a canvas and then saving it to a file.&lt;/p&gt;
&lt;p&gt;If you didn't, I recommend you read my &lt;a href="http://codeclimber.net.nz/archive/2019/05/22/raytracer-challenge-netcore-intro/"&gt;introductory post&lt;/a&gt; which explains what I'm trying to achieve and why.&lt;/p&gt;
&lt;h2&gt;Challenges encountered&lt;/h2&gt;
&lt;p&gt;This was a more straightforward exercise than the one in the previous chapter, but still, not everything was simple.&lt;/p&gt;
&lt;h3&gt;Modeling the Color class&lt;/h3&gt;
&lt;p&gt;The concept behind drawing images is very simple. An image is a matrix of pixels, and the value of each pixel is a color. And a color is a &amp;quot;tuple&amp;quot; of three values (the Red, Green, Blue components).&lt;/p&gt;
&lt;p&gt;For this reason, the author suggests refactoring the implementation of the &lt;code&gt;Tuple&lt;/code&gt; so that there is no need to reimplement the basic operations (add, subtract and multiplication by a scalar). I thought of creating a &lt;code&gt;TupleBase&lt;/code&gt; class, which extends &lt;code&gt;Array&lt;/code&gt; and implements those 3 operations on the array. Unfortunately, in C#, the &lt;code&gt;Array&lt;/code&gt; is a sealed class, and cannot be used as base class. I thought of using a &lt;code&gt;List&lt;/code&gt;, but it would probably with a very high-performance cost. I finally decided to just duplicate the code for the 3 operations, and come back to it after this chapter is done. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Color
{
    public static readonly Color Black = new Color(0, 0, 0);

    public Color(double r, double g, double b)
    {
        Red = r;
        Green = g;
        Blue = b;
    }

    public double Red { get; set; }
    public double Green { get; set; }
    public double Blue { get; set; }

    //All operations
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On my GitHub repository, you see the implementation till this point going the tag &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter-2.1"&gt;Chapter 2.1&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Modeling the Canvas class&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;Canvas&lt;/code&gt; class was pretty straightforward to implement. I used a bi-dimensional array to store the values and implemented an index accessor for setting and reading the values.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Canvas
{
    private Color[,] canvas;

    public Canvas(int width, int height) : this(width, height, Color.Black)
    {

    }
    public Canvas(int width, int height, Color background)
    {
        Width = width;
        Height = height;
        canvas = new Color[width, height];
        Initialize(background);
    }

    public int Width { get; set; }
    public int Height { get; set; }

    public Color this[int x, int y]
    {
        get
        {
            return canvas[x, y];
        }

        set
        {
            canvas[x, y] = value;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This indexer works fine, but intellisense doesn't show the name of the variables, and while writing the exercise I wish I wrote an explicit method to set the color of a pixel, like &lt;code&gt;Canvas.SetPixelAt(int x, int y, Color color)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On my GitHub repository, you see the implementation of the canvas on the tag &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter-2.2"&gt;Chapter 2.2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally, while writing this post I realized I could have used the same approach also for the base tuple class. I guess now I know how to refactor the implementation.&lt;/p&gt;
&lt;h3&gt;Implementing the PPM writer&lt;/h3&gt;
&lt;p&gt;The PPM file format is the most basic file format existing. Each pixel is represented with a string with the three components. If a pixel is white, it will be represented as &lt;code&gt;255 255 255&lt;/code&gt;, 12 bytes per pixel. While a black pixel will be 6 bytes. This makes it probably the most inefficient image format existing. I guess in my &amp;quot;refactoring sprint&amp;quot;, I'll try to implement a more efficient format.&lt;/p&gt;
&lt;p&gt;Each row of pixels is represented as a series of lines, of max 70 chars, so the code for rendering must also take care of this limit.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public string GetPPMContent()
{
    var builder = new StringBuilder();
    builder.AppendLine(&amp;quot;P3&amp;quot;);
    builder.AppendLine($&amp;quot;{Width} {Height}&amp;quot;);
    builder.AppendLine(&amp;quot;255&amp;quot;);
    for (int y = 0; y &amp;lt; Height; y++)
    {
        int lineLength = 0;
        for (int x = 0; x &amp;lt; Width; x++)
        {
            string[] colorA = canvas[x, y].ToRGBA();
            foreach (var color in colorA)
            {
                if (lineLength + 1 + color.Length &amp;gt; 70)
                {
                    builder.AppendLine();
                    lineLength = 0;
                }
                if(lineLength!=0)
                {
                    builder.Append(&amp;quot; &amp;quot;);
                    lineLength++;
                }
                builder.Append(color);
                lineLength += color.Length;
            }
        }
        builder.AppendLine();
    }
    return builder.ToString();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This algorithm works but doesn't feel right. Probably there is a more elegant way of doing it. More food for my refactoring sprint.&lt;/p&gt;
&lt;h2&gt;Putting it all together&lt;/h2&gt;
&lt;p&gt;With those basic image drawing methods implemented, the exercise for chapter 2 was drawing the trajectory implemented in the previous chapter. This was a pretty simple exercise. Only needed to make sure the trajectory felt inside the canvas.&lt;/p&gt;
&lt;p&gt;Here is the code for the method that plots the position of the projectile on the canvas, in red.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;private static void Draw(Canvas canvas, Tuple position)
{
    var x = (int)sys.Math.Round(position.X);
    var y = canvas.Height - (int)sys.Math.Round(position.Y) - 1;
    //sys.Console.WriteLine($&amp;quot; {x},{y} - {position}&amp;quot;);
    if (x &amp;gt;= 0 &amp;amp;&amp;amp; x &amp;lt;= canvas.Width - 1 &amp;amp;&amp;amp; y &amp;gt;= 0 &amp;amp;&amp;amp; y &amp;lt;= canvas.Height - 1)
    {
        canvas[x, y] = new Color(1, 0, 0);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The complex part of the exercise was finding some initial values that would produce something visible. The values used in chapter 1 would have fit in a 10 by 10 image. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var p = new Projectile(Tuple.Point(0, 0, 0), Tuple.Vector(1, 1, 0).Normalize());
var e = new Environment(Tuple.Vector(0, -0.1, 0), Tuple.Vector(-0.01, 0, 0));
var c = new Canvas(10, 10);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1061/4-trajectory-10x10.png" alt="10 by 10" /&gt;&lt;/p&gt;
&lt;p&gt;To generate something more visible I had to increase the velocity of the projectile by 11 (while keeping gravity and wind the same) and launched it at a steeper angle. And with these values, the chart fits into an image which is 900 per 550.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var p = new Projectile(Tuple.Point(0, 1, 0), Tuple.Vector(1, 1.8, 0).Normalize().Multiply(11.3));
var e = new Environment(Tuple.Vector(0, -0.1, 0), Tuple.Vector(-0.01, 0, 0));
var c = new Canvas(900, 550);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1062/4-trajectory-900x500.png" alt="900 by 550" /&gt;&lt;/p&gt;
&lt;p&gt;On my GitHub repository, you can have a look at the &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter2-End/Exercises/Chapter2/DrawProjectile"&gt;code of the exercise&lt;/a&gt;, and the output, both images, the &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/blob/Chapter2-End/Exercises/Chapter2/Results/file10x10.ppm"&gt;10x10&lt;/a&gt; and &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/blob/Chapter2-End/Exercises/Chapter2/Results/file-900x500.ppm"&gt;900x550&lt;/a&gt; sizes.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;This chapter was easier to implement than the previous one, but there is still something I'd love to improve. Specifically, I'd like to refactor the &lt;code&gt;Color&lt;/code&gt; implementation as child class of a &lt;code&gt;TupleBase&lt;/code&gt; shared with the other &lt;code&gt;Tuple&lt;/code&gt; class for point and vectors. Also, see if I can make the PPM serialization code a bit nicer and find a more storage efficient file format.&lt;/p&gt;
&lt;p&gt;Together with these tasks, I also want to go back to the basic primitives and implement math as operations overloads and do some performance testing to find the most performing data storage solution.&lt;/p&gt;
&lt;p&gt;If you like this series of posts and don't want to miss my next episode, please consider subscribing.&lt;/p&gt;
</description>
      <pubDate>Mon, 10 Jun 2019 16:51:24 Z</pubDate>
      <a10:updated>2019-06-10T16:51:24Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3399</guid>
      <link>http://codeclimber.net.nz/archive/2019/06/05/the-ray-tracer-challenge-implementing-primitives-and-vector-algebra-operations/</link>
      <title>The Ray Tracer Challenge - Implementing primitives and vector algebra operations</title>
      <description>&lt;p&gt;After setting up the project, in this post I start implementing the code for the first chapter of the &lt;a href="https://amzn.to/2Elaxkr"&gt;Ray tracing challenge book&lt;/a&gt;, which focuses mostly on defining primitives (Point and Vectors), and vector algebra operations like addition, subtraction and also dot and cross products. And a simple ballistic problem to put all the operations in practice.&lt;/p&gt;
&lt;p&gt;If you want to know more, you can read &lt;a href="http://codeclimber.net.nz/archive/2019/05/22/raytracer-challenge-netcore-intro/" title="The Ray Tracer Challenge... in .NET Core"&gt;the motivations about this &amp;quot;challenge&amp;quot; in my introductory post&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Challenges encountered&lt;/h2&gt;
&lt;p&gt;At first, it looked a simple task: how hard could it be to write some methods to perform simple addition, subtractions, and some other basic formulas?&lt;/p&gt;
&lt;p&gt;But it was not. &lt;/p&gt;
&lt;h3&gt;&amp;quot;Re-learning&amp;quot; vector algebra&lt;/h3&gt;
&lt;p&gt;The first main challenge was &amp;quot;re-learning&amp;quot; vector algebra, and the meaning of the various operations. The book explained well enough for the purpose of the implementation, but I wanted to understand a bit more, and Wikipedia helped a lot. Here some of the links I found:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Euclidean_vector"&gt;Euclidean vector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Dot_product"&gt;Dot product&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Cross_product"&gt;Cross product&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Modeling the primitives&lt;/h3&gt;
&lt;p&gt;The main primitive in the 3D space is a Tuple (of 4 elements), with the 3 coordinates (&lt;code&gt;x&lt;/code&gt;, &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;z&lt;/code&gt;) and a value (&lt;code&gt;w&lt;/code&gt;) to identify if it is either a vector (&lt;code&gt;w=0&lt;/code&gt;) or a point (&lt;code&gt;w=1&lt;/code&gt;). I don't know if this is a standard approach or just something the author of the book came up with. Additionally, in chapter 1 the reasoning is not explained but refers to a later chapter to better understand the meaning of this abstraction.&lt;/p&gt;
&lt;p&gt;In order to simplify the creation points and vectors, as tuples with the correct value for &lt;code&gt;w&lt;/code&gt;, it suggests creating factory methods.&lt;/p&gt;
&lt;p&gt;But the book uses pseudocode so that the ray tracer can be implemented in any language, both procedural and object-oriented. For this reason, no additional advice is given on how to actually implement it. &lt;/p&gt;
&lt;p&gt;I tried a few approaches.&lt;/p&gt;
&lt;h4&gt;Inheritance&lt;/h4&gt;
&lt;p&gt;Instead of creating factory methods, since C# is an object-oriented language, I implemented the primitives as a &lt;code&gt;Tuple&lt;/code&gt; base class, that implements all common operations, and two subclasses, &lt;code&gt;Point&lt;/code&gt; and &lt;code&gt;Vector&lt;/code&gt;, whose constructor sets the correct value for the &lt;code&gt;w&lt;/code&gt; parameter. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Tuple
{
    public Tuple(double x, double y, double z, double w)
    {
        X = x;
        Y = y;
        Z = z;
        W = w;
    }

    public double X { get; set; }
    public double Y { get; set; }
    public double Z { get; set; }
    public double W { get; set; }

    public Tuple Add(Tuple other)
    {
        return new Tuple(
            X + other.X,
            Y + other.Y,
            Z + other.Z,
            W + other.W
        );
    }

    // All other operations
    ...
}

public class Point : Tuple
{
    public Point(double x, double y, double z) : base(x, y, z, 1.0f) { }
}

public class Vector : Tuple
{
    public Vector(double x, double y, double z) : base(x, y, z, 0) { }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It all went fine in the implementation of the library, but things started to fail in the first exercise. The reason is that adding a &lt;code&gt;Point&lt;/code&gt; to a &lt;code&gt;Vector&lt;/code&gt; should produce a &lt;code&gt;Point&lt;/code&gt;. But with this inheritance scheme, that addition will create a &lt;code&gt;Tuple&lt;/code&gt; that cannot be cast to a &lt;code&gt;Point&lt;/code&gt;. It took me a while to understand that there is no way around this problem (it's actually how inheritance works).&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;Projectile&lt;/code&gt; (the exercise is a simple ballistic trajectory calculator) is defined as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public Projectile(Point position, Vector velocity)
{
    Position = position;
    Velocity = velocity;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When updating the position of the projectile after one &lt;em&gt;tick&lt;/em&gt; you have to add the current position to the current velocity. The result is logically another point (the new &lt;code&gt;w&lt;/code&gt; is &lt;code&gt;1+0=1&lt;/code&gt;), but the &lt;code&gt;Add&lt;/code&gt; method returns a new &lt;code&gt;Tuple&lt;/code&gt;, and this cannot be cast to a &lt;code&gt;Point&lt;/code&gt; later on.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public static Projectile Update(Projectile p, Environment e)
{
    return new Projectile(
        p.Position.Add(p.Velocity),
        p.Velocity.Add(e.Gravity).Add(e.Wind)
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can see far I went before getting stuck, on my repo, on branch &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter-1.2"&gt;Chapter 1.2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It's a pity this doesn't work because that would have allowed the most code re-use and keeping point and vector as two separate entities.&lt;/p&gt;
&lt;h4&gt;Inner value&lt;/h4&gt;
&lt;p&gt;I then started looking for another solution, to be able to keep the two separate objects, and I implemented them using the &amp;quot;inner value&amp;quot; approach (not sure it's the right name): both &lt;code&gt;Point&lt;/code&gt; and &lt;code&gt;Vector&lt;/code&gt; have an &amp;quot;innerValue&amp;quot; object of type &lt;code&gt;Tuple&lt;/code&gt; on which all operations are done. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Tuple
{
    public Tuple(double x, double y, double z, double w)
    {
        X = x;
        Y = y;
        Z = z;
        W = w;
    }

    public double X { get; set; }
    public double Y { get; set; }
    public double Z { get; set; }
    public double W { get; set; }

    public Tuple Add(Tuple other)
    {
        return new Tuple(
            X + other.X,
            Y + other.Y,
            Z + other.Z,
            W + other.W
        );
    }

    // All other operations
    ...
}

public class Point
{
    private Tuple _innerValue;

    public Tuple InnerValue { get =&amp;gt; _innerValue; set =&amp;gt; _innerValue = value; }

    public Point(double x, double y, double z)
    {
        InnerValue = new Tuple(x, y, z, 1);
    }

    public Point(Tuple tuple)
    {
        InnerValue = tuple;
    }

    public double X { get =&amp;gt; _innerValue.X; set =&amp;gt; _innerValue.X = value; }
    public double Y { get =&amp;gt; _innerValue.Y; set =&amp;gt; _innerValue.Y = value; }
    public double Z { get =&amp;gt; _innerValue.Z; set =&amp;gt; _innerValue.Z = value; }

    public Point Add(Vector other)
    {
        return new Point(InnerValue.Add(other.InnerValue));
    }
    // All other operations
}

public class Vector
{
    private Tuple _innerValue;

    public Tuple InnerValue { get =&amp;gt; _innerValue; set =&amp;gt; _innerValue = value; }

    public Vector(double x, double y, double z) 
    {
        InnerValue = new Tuple(x, y, z, 0);
    }

    public Vector(Tuple tuple)
    {
        InnerValue = tuple;
    }

    public double X { get =&amp;gt; _innerValue.X; set =&amp;gt; _innerValue.X = value; }
    public double Y { get =&amp;gt; _innerValue.Y; set =&amp;gt; _innerValue.Y = value; }
    public double Z { get =&amp;gt; _innerValue.Z; set =&amp;gt; _innerValue.Z = value; }

    public Vector Add(Vector other)
    {
        return new Vector(InnerValue.Add(other.InnerValue));
    }

    public Vector Add(Point other)
    {
        return new Vector(InnerValue.Add(other.InnerValue));
    }

    //All other operations

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This approach works, but, unlike the previous approach, I had to reimplement all methods, with the logic of the operation, was delegated to the &lt;code&gt;Tuple&lt;/code&gt;. The advantage of this approach is that it is possible to limit the operations (for example, you cannot add 2 points, or subtract a point from a vector) and specify the correct return type (the sum of two vectors is a vector, but the sum of a point and a vector is a point).&lt;/p&gt;
&lt;p&gt;This approach works, but it doesn't feel right. Too much code duplication.&lt;/p&gt;
&lt;p&gt;You can see how this was implemented on the branch &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/inner-element"&gt;inner-element&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;Using factory methods&lt;/h4&gt;
&lt;p&gt;Finally, I tried using to the suggestion of the author, and I deleted the two classes, only keeping the &lt;code&gt;Tuple&lt;/code&gt;, to which I added the 2 static factory methods to set the &lt;code&gt;w&lt;/code&gt; parameter for points (&lt;code&gt;w=1&lt;/code&gt;) and vectors (&lt;code&gt;w=0&lt;/code&gt;). The disadvantage is that I lose the possibility of limiting some operations to either point or vectors and that I cannot easily understand if a tuple is a point or a vector just by reading the code.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Tuple
{
    public static Tuple Point(double x, double y, double z)
    {
        return new Tuple(x, y, z, 1);
    }

    public static Tuple Vector(double x, double y, double z)
    {
        return new Tuple(x, y, z, 0);
    }

    public Tuple(double x, double y, double z, double w)
    {
        X = x;
        Y = y;
        Z = z;
        W = w;
    }

    public double X { get; set; }
    public double Y { get; set; }
    public double Z { get; set; }
    public double W { get; set; }

    public bool IsPoint { get =&amp;gt; W == 1; }
    public bool IsVector { get =&amp;gt; W == 0; }

    public Tuple Add(Tuple other)
    {
        return new Tuple(
            X + other.X,
            Y + other.Y,
            Z + other.Z,
            W + other.W
        );
    }

//All other operations

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This book adopts a TDD approach, so a data structure that works now might need some refactoring to support new features. For this reason, I finally decided to use the approach suggested by the author, of using factory methods. I will possibly come back on this decision later in the book when concepts become more clear.&lt;/p&gt;
&lt;p&gt;You can see how this was implemented on the branch &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/factory-methods"&gt;factory-methods&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Which data type to use&lt;/h3&gt;
&lt;p&gt;The book suggests using a &amp;quot;native&amp;quot; floating point data type since these values will be used a lot. I decided to use a &lt;code&gt;double&lt;/code&gt;, even if probably a &lt;code&gt;float&lt;/code&gt; would be enough, to avoid lots of casting given that all the &lt;code&gt;System.Math&lt;/code&gt; methods work with &lt;code&gt;Double&lt;/code&gt; types. And also I'm lazy and I don't want to add &lt;code&gt;f&lt;/code&gt; every time I want to specify a value as literal (just &lt;code&gt;1.7&lt;/code&gt; vs &lt;code&gt;1.7f&lt;/code&gt;).&lt;/p&gt;
&lt;h3&gt;Performances&lt;/h3&gt;
&lt;p&gt;I already see some performance issues in this code: creating a new object every time an operation is done will create zillions of objects, and memory will increase.&lt;/p&gt;
&lt;p&gt;Also using fields instead of properties, or using struct instead of classes might bring some performance improvement.&lt;/p&gt;
&lt;h2&gt;Putting it all together&lt;/h2&gt;
&lt;p&gt;As already mentioned above, the final exercise was about the &amp;quot;Hello World&amp;quot; exercise of vector and physics: the trajectory of a bullet shot with an initial velocity and subject to gravity and wind.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;using codeclimber.raytracer;
public class Environment
{
    public Environment(Tuple gravity, Tuple wind)
    {
        Gravity = gravity;
        Wind = wind;
    }

    public Tuple Gravity { get; set; }
    public Tuple Wind { get; set; }
}

public class Projectile
{
    public Projectile(Tuple position, Tuple velocity)
    {
        Position = position;
        Velocity = velocity;
    }

    public Tuple Position { get; set; }
    public Tuple Velocity { get; set; }

    public override string ToString()
    {
        return $&amp;quot;{Position} (v={Velocity})&amp;quot;;
    }
}

class Program
{
    static void Main(string[] args)
    {
        var p = new Projectile(Tuple.Point(0, 1, 0), Tuple.Vector(1, 1, 0).Normalize());
        var e = new Environment(Tuple.Vector(0, -0.1, 0), Tuple.Vector(-0.01, 0, 0));
        int i = 0;
        while (p.Position.Y &amp;gt;= 0)
        {
            i++;
            sys.Console.WriteLine($&amp;quot;{i} - {p}&amp;quot;);
            p = Update(p, e);
        }
    }

    public static Projectile Update(Projectile p, Environment e)
    {
        return new Projectile(
            p.Position.Add(p.Velocity),
            p.Velocity.Add(e.Gravity).Add(e.Wind)
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The code is that simple that it just prints out the list of coordinates.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1059/3-text-output.png?width=650" alt="Output of the projectile example" /&gt;&lt;/p&gt;
&lt;p&gt;To see I got it right, I imported the result in excel and drawn a chart.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1058/3-ballistic-trajectory.png?width=650" alt="Trajectory charted with Excel" /&gt;&lt;/p&gt;
&lt;p&gt;On my GitHub repository you can have a look at the &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter1-End/Exercises/Chapter%201"&gt;code of the exercise&lt;/a&gt;, and the output, both &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/blob/Chapter1-End/Exercises/Chapter%201/Results/trajectory.txt"&gt;text&lt;/a&gt; and &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/blob/Chapter1-End/Exercises/Chapter%201/Results/Projectile-trajectory.xlsx"&gt;Excel&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;The basic operations are now implemented. The next chapter in the book is about implementing the code to write images on disk, in &lt;a href="https://en.wikipedia.org/wiki/Netpbm_format"&gt;PPM format&lt;/a&gt; (I suppose the easiest format to implement).&lt;/p&gt;
&lt;p&gt;What do you think? Do you think there is a more elegant way to deal with &lt;code&gt;Point&lt;/code&gt; and &lt;code&gt;Vector&lt;/code&gt; other than using the two static factory methods? Anything else?&lt;/p&gt;
&lt;p&gt;I've posted the code already yesterday on my Github repo and I've received already two comments (as issues on my Github repo).&lt;/p&gt;
&lt;p&gt;One &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/issues/2"&gt;spotted a mistake&lt;/a&gt; I did and the other one posted &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/issues/1"&gt;some great suggestions&lt;/a&gt;. He suggested that I could use the new &lt;code&gt;System.MathF&lt;/code&gt; class introduced in .NET Core 2.1, to use floats instead of the double (but I'd still have to type the &lt;code&gt;f&lt;/code&gt; in literals). He also suggested I use operator overload instead of the methods &lt;code&gt;Add&lt;/code&gt;, &lt;code&gt;Subtract&lt;/code&gt;, and so on.&lt;/p&gt;
&lt;p&gt;I'll switch to operators overload and I'll do a bit of performance optimization before starting with calling these simple operation zillion times.&lt;/p&gt;
</description>
      <pubDate>Wed, 05 Jun 2019 11:46:11 Z</pubDate>
      <a10:updated>2019-06-05T11:46:11Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3395</guid>
      <link>http://codeclimber.net.nz/archive/2019/05/30/the-ray-tracer-challenge-setting-up-the-project-with-the-dotnet-cli/</link>
      <title>The Ray Tracer Challenge - Setting up the project with the dotnet CLI</title>
      <description>&lt;p&gt;Here it comes, the first post of my journey developing a Ray Tracer using .NET Core on a Mac, using only VS Code. If you didn't, I recommend you read my &lt;a href="http://codeclimber.net.nz/archive/2019/05/22/raytracer-challenge-netcore-intro/"&gt;introductory post&lt;/a&gt; which explains what I'm trying to achieve and why.&lt;/p&gt;
&lt;p&gt;In this first post I'll talk about the libraries and tools I decided to use, and how I setup the project structure using the &lt;code&gt;dotnet&lt;/code&gt; CLI.&lt;/p&gt;
&lt;h2&gt;Tools used&lt;/h2&gt;
&lt;p&gt;The only two tools I'm using are VS Code and the &lt;code&gt;dotnet&lt;/code&gt; CLI. Let's see how I configured the two.&lt;/p&gt;
&lt;h3&gt;VS Code&lt;/h3&gt;
&lt;p&gt;As I mentioned in the &lt;a href="http://codeclimber.net.nz/archive/2019/05/22/raytracer-challenge-netcore-intro/"&gt;introduction to this series of posts&lt;/a&gt;, I'm using VS Code, with the basic &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp"&gt;C#/Omnisharp extension&lt;/a&gt; that comes when you download VS Code. In addition, I'm using two other extensions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the &lt;a href="https://marketplace.visualstudio.com/items?itemName=jchannon.csharpextensions"&gt;C# Extensions&lt;/a&gt;, which adds some nice contextual menu and some additional refactoring;&lt;/li&gt;
&lt;li&gt;the &lt;a href="https://marketplace.visualstudio.com/items?itemName=formulahendry.dotnet-test-explorer"&gt;.NET Core Test Explorer&lt;/a&gt;, which adds a tree-view UI for all the tests in the workspace.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;dotnet CLI&lt;/h3&gt;
&lt;p&gt;The other tool I use, which comes with .NET Core, is the &lt;code&gt;dotnet&lt;/code&gt; CLI. One thing I learned while going through the documentation is that it supports TAB completion, but, in order to have it, it must be configured. You can follow the steps on the page &amp;quot;&lt;a href="https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete"&gt;How to enable TAB completion for .NET Core CLI&lt;/a&gt;&amp;quot; in .NET Core doc site.&lt;/p&gt;
&lt;p&gt;But, in short, add the following code to the &lt;code&gt;~/.bashrc&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# bash parameter completion for the dotnet CLI

_dotnet_bash_complete()
{
  local word=${COMP_WORDS[COMP_CWORD]}

  local completions
  completions=&amp;quot;$(dotnet complete --position &amp;quot;${COMP_POINT}&amp;quot; &amp;quot;${COMP_LINE}&amp;quot;)&amp;quot;

  COMPREPLY=( $(compgen -W &amp;quot;$completions&amp;quot; -- &amp;quot;$word&amp;quot;) )
}

complete -f -F _dotnet_bash_complete dotnet
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Normally Linux-based systems run this script every time the terminal is opened. But the default MacOS Terminal app runs another file, the &lt;code&gt;~/.bash_profile&lt;/code&gt; (which is normally executed only at login). Other terminals might behave differently, so it's better to add the script in both places. You can either copy the same code in the other file or just include the following lines in the &lt;code&gt;.bash_profile&lt;/code&gt; file, so that it automatically calls &lt;code&gt;.bashrc&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Libraries used: xUnit&lt;/h2&gt;
&lt;p&gt;I'm pretty sure some NuGet packages already exist to compute vector and matrix computations, and for saving images. But that would defeat the point of the whole exercise. The only external library I'm referencing is the testing framework.&lt;/p&gt;
&lt;p&gt;The book already provides the full test suite in Gherkin format to be used with Cucumber, so the obvious choice, to save time, would be to use the .NET counterpart of Cucumber: &lt;a href="https://specflow.org/"&gt;SpecFlow&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But despite &lt;a href="https://specflow.org/2019/specflow-3-is-here/"&gt;supporting .NET Core&lt;/a&gt;, it seems that SpecFlow relies heavily on its Visual Studio plugin in order to parse the feature files and generate the executable tests. I found some posts explaining how to do it without, but I'd rather start coding instead of spending time working around limitations of one specific testing framework. &lt;/p&gt;
&lt;p&gt;So I'll just start with xUnit, and after the first few chapters are completed, go back, try to make SpecFlow work on .NET Core without Visual Studio, and re-implement the tests.&lt;/p&gt;
&lt;h2&gt;Creating the project structure using the dotnet CLI&lt;/h2&gt;
&lt;p&gt;The project is simple: two projects (one .NET Standard class lib and one test project) and a solution to link them together.&lt;/p&gt;
&lt;p&gt;And here comes the first bit I learned in this process: the &lt;code&gt;dotnet&lt;/code&gt; CLI is awesome! You can create solution files, projects and also adding projects to solutions and adding references from one project to another.&lt;/p&gt;
&lt;p&gt;All without any manual editing of the files.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;dotnet new sln -o src -n ray-tracer-challenge
cd src
dotnet new classlib -o raytracer -n codeclimber.raytracer
dotnet new xunit -o xUnit -n codeclimber.raytracer.xUnit
dotnet sln add **/*.csproj
cd xUnit/
dotnet add reference ../raytracer/codeclimber.raytracer.csproj 
cd ..
dotnet build
dotnet test
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This list of commands creates a solution inside a folder called &lt;code&gt;src&lt;/code&gt; and 2 projects in their own sub-folders. Then it adds them to the solution, adds a reference from the testing project to the class library, and finally, build and run the tests.&lt;/p&gt;
&lt;p&gt;You can see the code at this point in time by going on the Github repo of this project and switching to the two branches:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter-0.1"&gt;Chapter 0.1&lt;/a&gt; - Just a script that uses the &lt;code&gt;dotnet&lt;/code&gt; CLI to create the project structure and makes sure everything is working fine.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/tree/Chapter-0.2"&gt;Chapter 0.2&lt;/a&gt; - The basic projects (lib and xUnit test lib) with simple code to make sure testing works fine.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Now that the environment is setup correctly, in the next post I'll start implementing the exercises of the first chapter of the book &lt;a href="https://amzn.to/2Elaxkr"&gt;The Ray Tracer Challenge - A Test-Driven Guide to Your First 3D Renderer&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;You can see the full list of posts in the &lt;a href="/archive/2019/05/22/raytracer-challenge-netcore-intro/"&gt;introduction to the series&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Thu, 30 May 2019 21:49:41 Z</pubDate>
      <a10:updated>2019-05-30T21:49:41Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3394</guid>
      <link>http://codeclimber.net.nz/archive/2019/05/29/codegarden-19-and-how-i-found-a-new-family/</link>
      <title>Codegarden 19 and how I found a new family</title>
      <description>&lt;p&gt;It's now a few days after &lt;a href="https://codegarden19.com/"&gt;Codegarden&lt;/a&gt;, and after resting a bit, I can sit down, look back and draw some conclusions.&lt;/p&gt;
&lt;h3&gt;Codegarden 19&lt;/h3&gt;
&lt;p&gt;This was my 7th Codegarden, but in a sense, it was my toughest. I was in a very bad mood when I arrived. It was due to many reasons, work-related, personal and even related to the community. It was so bad that the day before leaving I was even considering not going at all.  When I arrived I was grumpy, easily irritable, but then everything changed, even just after the pre-party. The people there were so friendly, everyone understood how I was feeling and the mood started rocketing. At the end of the 4th day, I was totally reborn. Such an amazing experience.&lt;/p&gt;
&lt;h3&gt;Why new &amp;quot;family&amp;quot;?&lt;/h3&gt;
&lt;p&gt;In the title, I say &lt;strong&gt;new&lt;/strong&gt; family. I might wonder why I say that. When I was in Italy, and the first years I was in Belgium, I was a very active member of the Italian ALT.NET community. I was part of the organizers. We organized a lot of successful conferences and all the members were really like family to me. But eventually the ALT.NET moment had no reason to exist anymore, and we closed the community. Then I came to Belgium, tried being part of the local community, but soon the local Microsoft developer evangelism group closed, and the community was Dutch-based and being the only non-Dutch speaker felt weird. And some individuals aside, I never really bonded with the people either.&lt;/p&gt;
&lt;p&gt;I attended lots of Codegardens and many other Umbraco conferences, I even contributed to the Core with some (accepted) PRs, but I never felt an active part of the community. There are so many bright and much more committed individuals that I didn't feel like I was bringing anything.&lt;/p&gt;
&lt;p&gt;Then came Codegarden 19, and all the amazing support received, the great discussions and inspiring talks, and I think I've now found a community I can call family. Or maybe it has always been, but I never realized it.&lt;/p&gt;
&lt;h3&gt;Way forward&lt;/h3&gt;
&lt;p&gt;This year I now want to contribute more, so I'd like to follow up on some of the ideas and inspirational talks from this year. And this year there is so much to do that I feel like a list is due:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Migrate my blogs (this and my test-bed blog) to v8&lt;/li&gt;
&lt;li&gt;Build a simple v8 content app/package&lt;/li&gt;
&lt;li&gt;Migrate my NuTranslation (better translation manager) to v8&lt;/li&gt;
&lt;li&gt;experiment more with Computer Vision API, Machine Learning&lt;/li&gt;
&lt;li&gt;experiment with building a chatbot backed by Umbraco&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But before I start any of these, I want to finish (or at least go a bit further) with my &lt;a href="http://codeclimber.net.nz/tags/raytracer-challenge"&gt;Raytracer challenge&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Wed, 29 May 2019 18:46:18 Z</pubDate>
      <a10:updated>2019-05-29T18:46:18Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3393</guid>
      <link>http://codeclimber.net.nz/archive/2019/05/22/raytracer-challenge-netcore-intro/</link>
      <title>The Ray Tracer Challenge... in .NET Core</title>
      <description>&lt;p&gt;I just bought the book &lt;a href="https://amzn.to/2Elaxkr"&gt;The Ray Tracer Challenge - A Test-Driven Guide to Your First 3D Renderer&lt;/a&gt; and in the upcoming months, I'll be developing my own ray tracer, in .NET Core.&lt;/p&gt;
&lt;p&gt;I will also document my learning experience on the blog, for me, to keep track of my progress, and maybe discuss some implementation decisions with you, my readers, but also to share what I learn in the process.&lt;/p&gt;
&lt;h2&gt;Why am I doing it&lt;/h2&gt;
&lt;p&gt;Nowadays I spend most of my time building CMS-based projects, using APIs provided by vendors, and aggregating results coming from Cloud-based services. And I stopped enjoying development.&lt;/p&gt;
&lt;p&gt;I needed a change, I needed to find back my love for developing, and I needed to challenge myself to learn something new. The book teaches the theory of a ray tracing, and, using a TDD approach, makes you implement, from scratch, all the pieces needed: starting from basic vector and matrix computations, to image processing and storing, and finally going into the real-deal of rendering 3D scenes from scratch.&lt;/p&gt;
&lt;p&gt;Rebuilding all the basic primitives might sound silly at first, in the current development world were developers reuse code and packages even for simple tasks as adding padding to strings. But the goal of the book is to help you rediscover the fun of developing from scratch, doing things yourself, without relying on stuff done by others.&lt;/p&gt;
&lt;h2&gt;Technologies used&lt;/h2&gt;
&lt;p&gt;The project will be implemented with .NET Core 2.2, with no external libraries, to adhere the most to the concept of the book, which is to build everything from scratch, even features that might exist already as part of .NET Standard or in other packages, like &lt;code&gt;Color&lt;/code&gt;, &lt;code&gt;Point&lt;/code&gt;, image rendering and serializing.&lt;/p&gt;
&lt;p&gt;My objective is also to build everything using a Mac, the &lt;code&gt;dotnet&lt;/code&gt; CLI and VS Code, to prove (mostly to myself) that this is a feasible approach, and that you can do everything you need without the full-blown Visual Studio.&lt;/p&gt;
&lt;p&gt;I'll also try to use the latest features of the C# language, whenever makes sense.&lt;/p&gt;
&lt;p&gt;The book recommends the usage of Cucumber for the testing and even provides the full set of features in Gherkin. SpecFlow is the only Gherkin implementation for .NET, but it seems like the support for .NET Core is not very advanced, and still relies on their Visual Studio plugin for generating the test files. So I'll start with plain old unit testing with xUnit, and will move to SpecFlow later.&lt;/p&gt;
&lt;h2&gt;What I'll be learning&lt;/h2&gt;
&lt;p&gt;Such a project will involve a lot of learning: I will learn new things, improve the knowledge I have and since there is a lot of math involved, I will re-learn things I've learned at the university.&lt;/p&gt;
&lt;p&gt;Specifically, things I hope to learn better are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Obviously, how raytracing works;&lt;/li&gt;
&lt;li&gt;Math, Algebra, Matrix, Vectors, and similar stuff;&lt;/li&gt;
&lt;li&gt;usage of the &lt;code&gt;dotnet&lt;/code&gt; CLI;&lt;/li&gt;
&lt;li&gt;a more advanced use of VS Code (now I mostly use it &amp;quot;just&amp;quot; as text editor);&lt;/li&gt;
&lt;li&gt;New features of C# (with new I mean from v6 onwards);&lt;/li&gt;
&lt;li&gt;xUnit;&lt;/li&gt;
&lt;li&gt;BDD with Gherkin and SpecFlow;&lt;/li&gt;
&lt;li&gt;Performance testing once everything is done.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Show me the code&lt;/h2&gt;
&lt;p&gt;All code is hosted on Github: https://github.com/simonech/ray-tracer-challenge-netcore.&lt;/p&gt;
&lt;p&gt;The repository will also include the posts of the series. To familiarize yourself with the structure of the repository, please have a look at the &lt;a href="https://github.com/simonech/ray-tracer-challenge-netcore/blob/master/README.md"&gt;README&lt;/a&gt; file.&lt;/p&gt;
&lt;h2&gt;Table of Content&lt;/h2&gt;
&lt;p&gt;I'll try to write a post at least once per chapter of the book, and document how things are going, the challenges I faced and what I learned. I will update this table of content with every post published&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Ray Tracer Challenge... in .NET Core - Introduction (this post)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2019/05/30/the-ray-tracer-challenge-setting-up-the-project-with-the-dotnet-cli/"&gt;The Ray Tracer Challenge - Setting up the project with the dotnet CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2019/06/05/the-ray-tracer-challenge-implementing-primitives-and-vector-algebra-operations/"&gt;The Ray Tracer Challenge - Implementing primitives and vector algebra operations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2019/06/24/how-to-run-micro-benchmarking-with-benchmarkdotnet-bonus-post-from-the-ray-tracer-challenge-series/"&gt;How to run micro-benchmarking with BenchmarkDotNet - Bonus post from The Ray Tracer Challenge series&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope you will subscribe to my blog (if you don't have already) and will learn together with my how implementing ray tracing in .NET Core.&lt;/p&gt;
</description>
      <pubDate>Wed, 22 May 2019 18:57:14 Z</pubDate>
      <a10:updated>2019-05-22T18:57:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3392</guid>
      <link>http://codeclimber.net.nz/archive/2019/05/09/moving-from-product-development-to-technology-expert/</link>
      <title>Moving from product development to technology expert</title>
      <description>&lt;p&gt;It's a while I'm not writing on my blog, but I feel the time has come to post a small &amp;quot;career&amp;quot; update, and given the new position I'll hopefully continue posting on a more regular basis.&lt;/p&gt;
&lt;p&gt;A bit more than 9 years ago &lt;a href="[https://link](http://codeclimber.net.nz/archive/2010/02/03/so-long-avanade-and-thanks-for-all-the-fish/)"&gt;I joined the Council of European Union&lt;/a&gt; as Lead Architect in the team working on the public web sites of the Council.&lt;/p&gt;
&lt;p&gt;And these have been 9 amazing years.&lt;/p&gt;
&lt;p&gt;We've launched the revamped version of the &lt;a href="https://www.consilium.europa.eu/"&gt;public website&lt;/a&gt; based on Umbraco (actually we also launched another version, based on another CMS, but that's another story), and all the customizations needed also made more involved into the Umbraco community, and started getting me into translation technologies, like &lt;a href="http://codeclimber.net.nz/tags/xliff"&gt;XLIFF&lt;/a&gt;. I discussed all of these topics in a talk at Codegarden 17, titled &lt;a href="[https://link](http://codeclimber.net.nz/archive/2017/06/09/how-we-implemented-a-multi-lingual-site-with-umbraco-at-the-council-of-eu/)"&gt;Fast and furious(ly) multilingual: Publishing of EU politics in 24 languages with Umbraco&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We've also launched another Umbraco based website, the video portal of the Council: &lt;a href="https://tvnewsroom.consilium.europa.eu/"&gt;TvNewsroom&lt;/a&gt;. This is also 100% running on Azure, making use of various cloud-native components, including &lt;a href="https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/"&gt;Computer Vision&lt;/a&gt; for automatic some part of the publishing workflow.&lt;/p&gt;
&lt;p&gt;What started as small technological island in our team, has now spread across the whole IT department: Umbraco has become the product of choice for building CMS-based projects (and we already have 3 additional projects running in production, even on the &amp;quot;headless&amp;quot; flavour, and more are coming in the future), Azure is starting to be adopted more and more, and XML-based export of translation is going to be implemented not only for translating the pages of the website but also for the &amp;quot;real deal&amp;quot;, which is official legislative documents.&lt;/p&gt;
&lt;p&gt;So, starting from last month (exactly 9 years after my start at the Council), I've joined the Development Architecture team, reporting directly to the Head of Unit of the Design and Development Unit. Here I'll oversee all Umbraco projects (avoiding other teams implement it &amp;quot;wrong&amp;quot;), will experiment with Umbraco v8 and how to migrate to the new version, I will make sure all teams know what Azure has to offer, and use it properly, and I will contribute to adoption of XLIFF across all document production.&lt;/p&gt;
&lt;p&gt;There will be less (or no) product development, which sometimes gets a bit boring now that we entered a more stable phase of the project, but there will be more experimentation of new features and technologies, and services. And the new position will force me to stay more up to date with what is happening.&lt;/p&gt;
&lt;p&gt;So, fun times ahead.&lt;/p&gt;
</description>
      <pubDate>Thu, 09 May 2019 09:15:38 Z</pubDate>
      <a10:updated>2019-05-09T09:15:38Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3391</guid>
      <link>http://codeclimber.net.nz/archive/2018/05/22/codegarden18-git-xliff2-ci-cd/</link>
      <title>Codegarden 2018: talking about git, CI/CD and Xliff</title>
      <description>&lt;p&gt;During the next three days I'll be attending at Umbraco &lt;a href="http://codegarden18.com/"&gt;Codegarden 2018&lt;/a&gt;, and together with a colleague we are going to share some insights on how we make sure our team of 10+ developers and designers doesn't mess up our Umbraco solution, how we do automated build and deployment of Umbraco project and how we customised Umbraco to export translation requests in Xliff v2.0.&lt;/p&gt;
&lt;p&gt;In details here are our talks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codegarden18.com/sessions/building-umbraco-websites-in-big-teams/"&gt;Building Umbraco websites in big teams&lt;/a&gt; (Wed May 23rd, 15:00, Main Stage)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codegarden18.com/sessions/ask-us-anything-about-the-council-of-european-union-website/"&gt;Ask us anything about the Council of European Union website&lt;/a&gt; (Thu May 24th, 11:15, Lightning Talk)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codegarden18.com/sessions/extending-the-umbraco-backend-to-translate-content-in-24-languages-with-xliff-v20/"&gt;Extending the Umbraco backend to translate content in 24 languages with XLIFF v2.0&lt;/a&gt; (Thu May 24th, 11:5, Lightning Talk)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you come and attend one our my talk, you might have the chance to win a copy my book, &lt;a href="https://amzn.to/2s62lxk"&gt;Front-end Development with ASP.NET Core, Angular, and Bootstrap&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;See you at CG18&lt;/p&gt;</description>
      <pubDate>Tue, 22 May 2018 22:09:44 Z</pubDate>
      <a10:updated>2018-05-22T22:09:44Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3389</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/24/preface-to-frontend-development-with-aspnet-core-mvc-angular-and-bootstrap-day-24/</link>
      <title>Preface to Frontend development with ASP.NET Core MVC, Angular and Bootstrap - Day 24</title>
      <description>&lt;p&gt;On the last day of my 24 days of Christmas from &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book Front-end Development with ASP.NET Core, Angular, and Bootstrap&lt;/a&gt; I want to share the preface to the book written by &lt;a href="https://madskristensen.net/"&gt;Mads Kristensen&lt;/a&gt;, PM in the Visual Studio team at Microsoft. &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The web becomes an increasingly capable platform with each new browser
release. Tomorrow’s new features become available to early adopters
while yesterday’s stabilize for mass adoption. This ever-growing
toolbox of HTML, CSS, and JavaScript capabilities seems to be
accelerating and shows no signs of slowing down. In fact, it’s growing
so fast that specialized tooling is required to take advantage of
these new features – tooling such as WebPack and Gulp. &lt;/p&gt;
&lt;p&gt;The amount of knowledge required to build modern browser applications
is illustrated by the new job title “front-end engineer” – a term that
didn’t exist just a few years ago. &lt;/p&gt;
&lt;p&gt;In addition to the advances in the web platform, the server-side
technologies powering the web are evolving as well. To provide the
best experience for both end-users and web developers, the server-side
platform must be ultra-fast, secure, cross-platform, cloud scalable
and have great tooling. &lt;/p&gt;
&lt;p&gt;Most web applications consist of client-side code running in the
browser and server-side code running on one or more servers. So, to be
a proficient web developer it is necessary to know enough of both
client- and server technologies and that is a big challenge. Because
how much is enough and how much time should we devote to continuously
learning? &lt;/p&gt;
&lt;p&gt;One way to make it easier for ourselves is to choose the right set of
frameworks and tools to build our applications upon. Frameworks are
useful because they usually wrap complex platform features into
easy-to-use components, so web developers can focus on writing their
applications logic instead of all the plumbing needed to work with the
browser or server platforms. &lt;/p&gt;
&lt;p&gt;Choosing the right frameworks is important. The options are many, but
here are a few that have shown to be particularly well suited for
building modern web applications. ASP.NET Core as the application
framework for the server and Angular for the client is a great
combination. Bootstrap makes sure the app looks good in all browsers
and on all types of devices. &lt;/p&gt;
&lt;p&gt;Simone has done a great job showing how these frameworks complement
each other and how tooling provides a great development experience. In
the fast-moving world of web development, it is good we have books
like this to give us a pragmatic approach to building web applications
using the latest and greatest in both client- and server technologies.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;With this post I conclude the series. If you liked it, I encourage you to go &lt;a href="http://amzn.to/2hDX37c"&gt;pre-order my book&lt;/a&gt; and now enjoy you season holidays!&lt;/p&gt;
</description>
      <pubDate>Sun, 24 Dec 2017 12:30:32 Z</pubDate>
      <a10:updated>2017-12-24T12:30:32Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3390</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/23/the-book-table-of-content-day-23-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>The book Table of Content - Day 23 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;With the series coming to an end, it's time to look back at these last 22 days of content, and see how they relate to the outline of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;.&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Introduction
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/01/polyglot-developer-day-1-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 1 - Polyglot Developer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 1: What's new in ASP.NET Core MVC
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/02/web-host-builder-in-aspnet-core-20-day-2-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 2 - Web Host Builder in ASP.NET Core 2.0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/03/taghelper-syntax-for-view-components-day-3-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 3 - TagHelper syntax for View Components&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 2: The Front-End Developer Toolset
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/04/the-front-end-developer-toolset-day-4-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 4 - The Front-end developer toolset&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/05/not-just-bootstrap-semantic-ui-day-5-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 5: Not just Bootstrap: Semantic UI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 3: Angular in a Nutshell
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/06/angular-concepts-day-6-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 6 - Angular Concepts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/07/how-an-angular-project-is-built-day-7-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 7 - How an Angular project is built&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/08/javascriptservices-day-8-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 8 - JavaScriptServices&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 4: Bootstrap in a Nutshell
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/09/bootstrap-responsive-grid-system-day-9-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 9 - Bootstrap Responsive Grid System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/10/bootstrap-snippet-pack-for-visual-studio-day-10-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 10 - Bootstrap Snippet Pack for Visual Studio&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 5: Managing dependencies with NuGet and Bower
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/11/what-are-package-managers-and-why-we-need-them-day-11-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 11 - What are package managers and why we need them&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/12/how-to-publish-your-own-nuget-package-day-12-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 12 - How to publish your own Nuget Package&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 6: Building your application with Gulp and webpack
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/13/what-is-the-role-of-build-systems-in-front-end-development-day-13-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 13 - What is the role of build systems in front-end development&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/14/introduction-to-webpack-day-14-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 14 - Introduction to webpack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 7: Deploying ASP.NET Core
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/15/deploy-aspnet-core-apps-on-iis-day-15-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 15 - Deploy ASP.NET Core apps on IIS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/16/deploy-aspnet-core-apps-to-azure-day-16-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 16 - Deploy ASP.NET Core apps to Azure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/17/continuous-deployment-on-azure-git-day-17-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 17 - Continuous Deployment on Azure with Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 8: Developing outside of Windows
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/18/omnisharp-the-tooling-behind-the-c-integration-in-vs-code-day-18-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 18 - Omnisharp: the tooling behind the C# integration in Visual Studio Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/19/git-support-in-vs-code-day-19-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 19 - Git support in VS Code&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Chapter 9: Chapter 9: Putting It All Together
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/20/entity-framework-core-migration-day-20-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 20 - Entity Framework Core migration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/21/how-to-seed-you-database-with-ef-core-day-21-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 21 - How to seed your database with EF Core&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/22/how-to-add-social-media-authentication-to-aspnet-core-day-22-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Day 22 - How to add Social Media Authentication to ASP.NET Core&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>Sat, 23 Dec 2017 12:30:18 Z</pubDate>
      <a10:updated>2017-12-23T12:30:18Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3384</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/22/how-to-add-social-media-authentication-to-aspnet-core-day-22-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>How to add Social Media Authentication to ASPNET Core - Day 22 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;It's day 22 and till now I've shared two or three extracts from all the chapters, in the order in which they appear on &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;. For today I'll still share something from the last chapter: how to enable social media authorization to an ASP.NET Core application. &lt;/p&gt;
&lt;p&gt;Adding social media authentication is easy with ASP.NET Core. You start by creating another project, still as an ASP.NET Core MVC project, and selecting &lt;strong&gt;Individual User Accounts&lt;/strong&gt; as the Authentication mode. This way the project template will add the database entities, controllers, and views to collect and store all the information needed to create a private site where users can register either directly (providing a username and password) or via OAuth providers like Facebook, Twitter, Google, Microsoft, GitHub, and others.&lt;/p&gt;
&lt;p&gt;Adding a social login is just a matter of adding the right Nuget package and configuring the authentication provider in the &lt;code&gt;ConfigureService&lt;/code&gt; method in the Startup class. For example, to add a Facebook login, add the Nuget package &lt;code&gt;Microsoft.AspNetCore.Authentication.Facebook&lt;/code&gt;. Then add the following lines of code in the &lt;code&gt;ConfigureService&lt;/code&gt; method:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;services.AddAuthentication().AddFacebook(facebookOptions =&amp;gt;
{
    facebookOptions.AppId = Configuration[&amp;quot;Authentication:Facebook:AppId&amp;quot;];
    facebookOptions.AppSecret = Configuration[&amp;quot;Authentication:Facebook:AppSecret&amp;quot;];
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you have to register a new application on the Facebook developer portal in order to get the AppId and AppSecret needed to authenticate your application with Facebook. Go to the URL https://developers.facebook.com/apps/ and click on the Add a New App button and add the basic information for your app. Once done go the settings and enter the URL for the OAuth redirect page, which is &lt;code&gt;/signin-facebook&lt;/code&gt; (but you need to specify the absolute URL, so also &lt;code&gt;http://localhost:nnn&lt;/code&gt;). This route is added by the Nuget package for the Facebook authentication.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1048/facebook_url_callback.png" alt="Facebook Application Settings" /&gt;&lt;/p&gt;
&lt;p&gt;The last thing is to retrieve the &lt;code&gt;AppId&lt;/code&gt; and &lt;code&gt;AppSecrets&lt;/code&gt; needed for the application to work. For this go to the Dashboard inside the developer portal &lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1049/facebook_app_settings.png" alt="Facebook Application Id and Secrets" /&gt;&lt;/p&gt;
&lt;p&gt;Now that you have these values, you have to store them in the settings of your application. Since these are sensitive data, you don't want to accidentally commit them to a public source repository, so it's better to store them in the User Secrets.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1050/app_user_secrets.png" alt="User Secrets" /&gt;&lt;/p&gt;
&lt;p&gt;The file is stored in the user profile, still easily readable, but in theory only by its owner. The in production these information can be passed to the app in different ways, like shown when explaining the &lt;a href="http://codeclimber.net.nz/archive/2017/12/02/web-host-builder-in-aspnet-core-20-day-2-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;configuration of app settings inside the WebHost&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  &amp;quot;Authentication&amp;quot;: {
    &amp;quot;Facebook&amp;quot;: {
      &amp;quot;AppId&amp;quot;: &amp;quot;myappId&amp;quot;,
      &amp;quot;AppSecret&amp;quot;: &amp;quot;myappsecret&amp;quot;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now just launch the site and you'll see a new button to sign-in and log-in via Facebook.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1051/login_social.png" alt="Login via social media" /&gt;&lt;/p&gt;
&lt;p&gt;This post is an extract of chapter 9 of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;. To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Fri, 22 Dec 2017 10:27:26 Z</pubDate>
      <a10:updated>2017-12-22T10:27:26Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3383</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/21/how-to-seed-you-database-with-ef-core-day-21-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>How to seed your database with EF Core - Day 21 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;Yesterday I've shown &lt;a href="http://codeclimber.net.nz/archive/2017/12/20/entity-framework-core-migration-day-20-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;how to do EF Core DB migrations&lt;/a&gt; using either the Package Manager Console or the dotnet CLI. But you can also do these code migrations automatically, triggering them via code.&lt;/p&gt;
&lt;p&gt;After following &lt;a href="http://codeclimber.net.nz/archive/2017/12/20/entity-framework-core-migration-day-20-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;the steps shown yesterday&lt;/a&gt;, you have all your migrations setup, and you can apply the DB changes using the &lt;code&gt;dotnet&lt;/code&gt; CLI. But there is less-know feature, still experimental and not ironed out completely, that makes it possible to run migrations from code, and even seeding the DB with initial data.&lt;/p&gt;
&lt;h2&gt;Apply migrations with code&lt;/h2&gt;
&lt;p&gt;To just apply migrations you need to call the &lt;code&gt;db.Database.Migrate()&lt;/code&gt; method, where &lt;code&gt;db&lt;/code&gt; is the EF Context.&lt;/p&gt;
&lt;p&gt;Typically the following is the code needed to run the migration in code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public static void Initialize(IServiceProvider service)
{
    using (var serviceScope = service.CreateScope())
    {
        var scopeServiceProvider = serviceScope.ServiceProvider;
        var db = scopeServiceProvider.GetService&amp;lt;TriathlonRaceTrackingContext&amp;gt;();
        db.Database.Migrate();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This method can be called in the &lt;code&gt;Configure&lt;/code&gt; method in the &lt;code&gt;Startup&lt;/code&gt; class:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
  ...
  Initialize(app.ApplicationServices);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Seeding the DB with data&lt;/h2&gt;
&lt;p&gt;As part of the database initialization you can also add some initial test data to the database. Unfortunately it is not that automated as in Entity Framework 6, but can be coded manually.&lt;/p&gt;
&lt;p&gt;For, example, to add a new entry in the &lt;code&gt;Race&lt;/code&gt; table, to code is as following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;private static async Task InsertTestData(TriathlonRaceTrackingContext context)
{
    if(context.Races.Any())
        return;
    var race = new Race { Name=&amp;quot;Ironman World Championship 2017&amp;quot;,Location=&amp;quot;Kona, Hawaii&amp;quot;,Date=new DateTime(2017,10,14,7,0,0) };
    context.Add(race);
    await context.SaveChangesAsync();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The advantage of having to code it yourself is that you can decide if/when/how to seed the database. In this I just do it if the &lt;code&gt;Race&lt;/code&gt; table is empty. But I could have decided to always wipe it clean, or anything else.&lt;/p&gt;
&lt;p&gt;To include data seeding into the &lt;code&gt;Initialize&lt;/code&gt; method, a few changes have to made as the data seeding is an async method. So the &lt;code&gt;Initialize&lt;/code&gt; becomes an &lt;code&gt;InitializeAsync&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public static async Task InitializeAsync(IServiceProvider service)
{
    using (var serviceScope = service.CreateScope())
    {
        var scopeServiceProvider = serviceScope.ServiceProvider;
        var db = scopeServiceProvider.GetService&amp;lt;TriathlonRaceTrackingContext&amp;gt;();
        db.Database.Migrate();
        await InsertTestData(db);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Also the call from the &lt;code&gt;Configure&lt;/code&gt; method must be slightly changed into &lt;code&gt;InitializeAsync(app.ApplicationServices).Wait();&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This post is an extract of chapter 9 of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;. To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Thu, 21 Dec 2017 12:00:01 Z</pubDate>
      <a10:updated>2017-12-21T12:00:01Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3382</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/20/entity-framework-core-migration-day-20-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Entity Framework Core migration - Day 20 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;In the last chapter of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt; I build a very simple application to show how all the various technologies play together, and also to show some features that are not specific to front-end development but are needed in a real world application.&lt;/p&gt;
&lt;p&gt;One of the technologies I don't cover in the other chapters of the book but is covered in the last chapter is Entity Framework Core. Today I'm showing is loosely taken from the section about EF Migrations.&lt;/p&gt;
&lt;p&gt;Let's say you have a class called &lt;code&gt;Race&lt;/code&gt; defined by the following lines of code&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Race
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Location { get; set; }
    public DateTime Date { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In order to work, EF Core needs to know the mapping between database tables, fields and properties of classes. The easiest approach, unless you want to write a lot of mapping code yourself, is to just stick to the default mapping conventions, and name tables and columns accordingly. And the best way of doing it, is to let EF generate the database for you. And this is done with a feature of EF called &lt;em&gt;migrations&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Migrations can be used for the first setup of the database but more importantly later in the development when adding more features that require new tables or columns for existing tables.&lt;/p&gt;
&lt;p&gt;To create the baseline migration for the class &lt;code&gt;Race&lt;/code&gt;, you need to run the &lt;strong&gt;Add Migration&lt;/strong&gt; command to generate the code to create the database schema (it gets stored in the Migrations folder), followed by the &lt;strong&gt;Update Database&lt;/strong&gt; command to run this code on the database.&lt;/p&gt;
&lt;p&gt;These two commands can be run either inside Visual Studio 2017, the Package Manager Console, or using the dotnet command-line tool.
In the first option type the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;PM&amp;gt;Add-Migration Initial
PM&amp;gt;Update-Database
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you prefer using the dotnet command line, type these lines in the command prompt (but first you need to add the &lt;code&gt;Microsoft.EntityFrameworkCore.Tools.DotNet&lt;/code&gt; package to the &lt;code&gt;DotNetCliToolReference&lt;/code&gt; to the &lt;code&gt;.csproj&lt;/code&gt; file).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;dotnet ef migration Initial
&amp;gt;dotnet ef database update
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The table is created in the database configured in the &lt;code&gt;appsettings.json&lt;/code&gt; file, under the &lt;code&gt;ConnectionSettings&lt;/code&gt; section.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1045/ef_tables.png" alt="Tables generated by EF Core migrations" /&gt;&lt;/p&gt;
&lt;p&gt;In the case of the &lt;code&gt;Race&lt;/code&gt; class, the migration code generated is the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;migrationBuilder.CreateTable(
    name: &amp;quot;Race&amp;quot;,
    columns: table =&amp;gt; new
    {
        ID = table.Column&amp;lt;int&amp;gt;(type: &amp;quot;int&amp;quot;, nullable: false)
            .Annotation(&amp;quot;SqlServer:ValueGenerationStrategy&amp;quot;, SqlServerValueGenerationStrategy.IdentityColumn),
        Date = table.Column&amp;lt;DateTime&amp;gt;(type: &amp;quot;datetime2&amp;quot;, nullable: false),
        Location = table.Column&amp;lt;string&amp;gt;(type: &amp;quot;nvarchar(max)&amp;quot;, nullable: true),
        Name = table.Column&amp;lt;string&amp;gt;(type: &amp;quot;nvarchar(max)&amp;quot;, nullable: true)
    },
    constraints: table =&amp;gt;
    {
        table.PrimaryKey(&amp;quot;PK_Race&amp;quot;, x =&amp;gt; x.ID);
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And the following mapping code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;modelBuilder.Entity(&amp;quot;TriathlonRaceTracking.Models.Race&amp;quot;, b =&amp;gt;
    {
        b.Property&amp;lt;int&amp;gt;(&amp;quot;ID&amp;quot;)
            .ValueGeneratedOnAdd();
        b.Property&amp;lt;DateTime&amp;gt;(&amp;quot;Date&amp;quot;);
        b.Property&amp;lt;string&amp;gt;(&amp;quot;Location&amp;quot;);
        b.Property&amp;lt;string&amp;gt;(&amp;quot;Name&amp;quot;);
        b.HasKey(&amp;quot;ID&amp;quot;);
        b.ToTable(&amp;quot;Race&amp;quot;);
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This post is an extract of chapter 9 of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;. Tomorrow I'll continue covering Entity Framework Core migrations.&lt;/p&gt;
&lt;p&gt;To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Wed, 20 Dec 2017 12:46:23 Z</pubDate>
      <a10:updated>2017-12-20T12:46:23Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3380</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/19/git-support-in-vs-code-day-19-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Git support in VS Code  - Day 19 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;Visual Studio Code comes with native support for Source Control systems. Let's see how it integrates with Git.&lt;/p&gt;
&lt;p&gt;Originally Visual Studio Code came with native support for Git, but recently, in order to allow support for other systems, also the source control support became an external plugin. At the moment there &lt;a href="https://marketplace.visualstudio.com/search?target=VSCode&amp;amp;category=SCM%20Providers&amp;amp;sortBy=Downloads"&gt;six SCM provider&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let's have a look at my favorite features of the Git support in Visual Studio Code.&lt;/p&gt;
&lt;p&gt;The one I like the most, and was just recently added is the visual representation of which files have changed directly in the file explorer view.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1042/explorer.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;Another feature I like is the diff view, which can be both side by side or inline.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1041/sidebyside-diff.png" alt="enter image description here" /&gt;
&lt;img src="http://codeclimber.net.nz/media/1040/inlinediff.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;And diff can also be displayed by simply clicking on the gutter.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1038/inwindow-diff.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;Another feature I like is the easy procedure for committing code: just type the message and you can commit all the changes. Or you can also choose which changes to commit.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1039/staged-changes.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;And once committed, the status bar shows that there is a pending commit&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1043/status-bar.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;Also, in the command palette, there are accessible most of the git commands, like branch, checkout, clone, merge, commit, ecc...&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1037/comand-palette.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;But to really enhance the experience using Git in VS Code, I recommend also checking out two very useful extensions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory"&gt;Git history&lt;/a&gt; which adds, as the name suggests, possibility of reading the change logs, compare between commits and see a graph of all commits, branches and merges&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens"&gt;Git Lens&lt;/a&gt; which adds code lens features (so small overlay next to lines of code showing when and by who it was changed) and much more&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This article contained some of the pieces that didn't make into chapter 8 of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt; because to volatile for a printed book. So consider this a &amp;quot;bonus&amp;quot; section.&lt;/p&gt;
&lt;p&gt;To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Tue, 19 Dec 2017 12:57:10 Z</pubDate>
      <a10:updated>2017-12-19T12:57:10Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3371</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/18/omnisharp-the-tooling-behind-the-c-integration-in-vs-code-day-18-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Omnisharp: the tooling behind the C# integration in VS Code - Day 18 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;We are entering the last week of the calendar, and we are also reaching the end of the book. Today is time to look at the cross-platform tools used to develop ASP.NET Core application on any platform. We'll have a look at Visual Studio Code, and specifically how the C# integration works.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt; is just a simple text editor, with no language-specific features or knowledge. All language-specific tools are coming as external extensions, either developed by Microsoft or by the community.&lt;/p&gt;
&lt;p&gt;So how can Visual Studio Code show Intellisense when you type .NET code, or provide refactoring suggestions or show compilation errors in real time? This is done using &lt;a href="http://www.omnisharp.net/"&gt;Omnisharp&lt;/a&gt;. Here is an extract from chapter 8 of book, which briefly explains what Omnisharp is.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;All these features, as far as their support for .NET Core is
concerned, are possible thanks to OmniSharp. OmniSharp is a set of OSS
projects that work together for bringing .NET development to any text
editor.&lt;/p&gt;
&lt;p&gt;The base layer is a server that runs Roslyn and analyzes the files of
the project that is open inside the editor.&lt;/p&gt;
&lt;p&gt;On top of this there is an API (REST-based over HTTP or over pipes)
that allows clients (text editors via their extensions) to query the
code model to get intellisense, parameter information, the references
to a variable, or the definition of a method. At the top layer are all
the editor-specific extensions that display the information retrieved
from the OmniSharp server in a user-friendly way. The top layer also
includes other features that are purely client-side such as code
formatting or snippet expansion. It is also the extensions that
interact with the debugger to provide all the features needed for
debugging your code.&lt;/p&gt;
&lt;p&gt;OmniSharp extensions have been developed for the most popular text
editors on the market. Apart from Visual Studio Code, there are
extensions for Atom, Vim, Sublime, and even Emacs. This means that you
can continue using your favorite text editor and still be able to get
all the benefit of a rich code-editing experience powered by
OmniSharp.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This article was short summary of the chapter about deploying ASP.NET Core from &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Mon, 18 Dec 2017 12:56:01 Z</pubDate>
      <a10:updated>2017-12-18T12:56:01Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3370</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/17/continuous-deployment-on-azure-git-day-17-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Continuous Deployment on Azure Git - Day 17 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;&lt;a href="http://codeclimber.net.nz/archive/2017/12/16/deploy-aspnet-core-apps-to-azure-day-16-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Deploying to Azure&lt;/a&gt; can be done with WebDeploy, as seen yesterday, but we can also go one step further and setup a continuous deployment using Git.&lt;/p&gt;
&lt;p&gt;The first step is to create the App Service directly in the Azure portal, and then configure the Deployment Source.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1032/cd-options.png" alt="Deployment Source" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see from the image you can select Visual Studio Team Services, a local Git repository or hosted git like Github or Bitbucket, or even file storage like Drobpox or OneDrive.&lt;/p&gt;
&lt;p&gt;The easist solution is configuring a Local repository directly in Visual Studio and then add as additional remote the git repository just created from the portal (the url can be found in the overview of the Azure App Service). This can be done either from within Visual Studio or with the Git command line.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1034/setup-remote.png" alt="Configure Git remote" /&gt;&lt;/p&gt;
&lt;p&gt;Now the code can be pushed to the remote, either directly from Visual Studio or from the command line. As part of the push operation, Azure launches the publish command, which restores all NuGet packages and builds the application using the project file. Every time a commit is pushed to the repository, the publish process starts, effectively implementing a continuous deployment scenario.&lt;/p&gt;
&lt;p&gt;If you created the remote within Visual Studio, the remote is not tracked by the local repository, so the first time you want to push, you have to do it from the Command Prompt and type: &lt;code&gt;git push -u azure master&lt;/code&gt;. The &lt;code&gt;-u&lt;/code&gt; option instructs git to start tracking the remote branch.&lt;/p&gt;
&lt;p&gt;On Azure portal you can see the list of deployments and the log message for each commit. &lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1033/git-log.png" alt="List of deployments" /&gt;&lt;/p&gt;
&lt;p&gt;This article was short summary of the chapter about deploying ASP.NET Core from &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Sun, 17 Dec 2017 12:40:46 Z</pubDate>
      <a10:updated>2017-12-17T12:40:46Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3366</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/16/deploy-aspnet-core-apps-to-azure-day-16-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Deploy ASP.NET Core apps to Azure - Day 16 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;Yesterday we've seen &lt;a href="http://codeclimber.net.nz/archive/2017/12/15/deploy-aspnet-core-apps-on-iis-day-15-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;how to deploy an ASP.NET Core app to IIS&lt;/a&gt;, and today we look at how to do the same on Azure.&lt;/p&gt;
&lt;p&gt;Publishing on Azure is super-simple and can be easily done from within Visual Studio.&lt;/p&gt;
&lt;p&gt;From the overview screen of the project, just select &amp;quot;Publish&amp;quot; and then &amp;quot;Microsoft Azure App Service&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1029/publish_azure.png" alt="Publish Dialog" /&gt;&lt;/p&gt;
&lt;p&gt;You can then either select an existing App Service or create a new one directly from the Publish dialog, without going to the Azure Portal.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1030/publish_azure1.png" alt="Publish Dialog" /&gt;&lt;/p&gt;
&lt;p&gt;One thing I recommend doing is also creating a new Resource Group and service plan (if you are just testing, remember to select the Free size).&lt;/p&gt;
&lt;p&gt;So, nothing different from a standard ASP.NET application. The only difference is that the actual publishing consists on Visual Studio running &lt;code&gt;dotnet publish&lt;/code&gt; to create the file bundle on a temporary folder, followed by Web Deploy moving the files to the server.&lt;/p&gt;
&lt;p&gt;There is another way of deploying applications to Azure, and it is done via Git. But this is something for another day.&lt;/p&gt;
&lt;p&gt;This article was short summary of the chapter about deploying ASP.NET Core from &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Sat, 16 Dec 2017 12:12:34 Z</pubDate>
      <a10:updated>2017-12-16T12:12:34Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3362</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/15/deploy-aspnet-core-apps-on-iis-day-15-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Deploy ASP.NET Core apps on IIS - Day 15 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;After developing the &lt;a href="http://codeclimber.net.nz/archive/2017/12/02/web-host-builder-in-aspnet-core-20-day-2-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;ASP.NET Core&lt;/a&gt; &lt;a href="http://codeclimber.net.nz/archive/2017/12/03/taghelper-syntax-for-view-components-day-3-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;application&lt;/a&gt;, adding client-side interactivity with &lt;a href="http://codeclimber.net.nz/archive/2017/12/06/angular-concepts-day-6-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Angular&lt;/a&gt; and styling with &lt;a href="http://codeclimber.net.nz/archive/2017/12/09/bootstrap-responsive-grid-system-day-9-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Bootstrap&lt;/a&gt;, all automated using &lt;a href="http://codeclimber.net.nz/archive/2017/12/14/introduction-to-webpack-day-14-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;webpack&lt;/a&gt; and with &lt;a href="http://codeclimber.net.nz/archive/2017/12/11/what-are-package-managers-and-why-we-need-them-day-11-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;dependencies&lt;/a&gt; managed with &lt;a href="http://codeclimber.net.nz/archive/2017/12/12/how-to-publish-your-own-nuget-package-day-12-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Nuget&lt;/a&gt;, the time has come to deploy the application.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://amzn.to/2hDX37c"&gt;My upcoming &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot; book&lt;/a&gt; explains how to deploy ASP.NET Core applications with three different methods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On-Prem on IIS&lt;/li&gt;
&lt;li&gt;On Azure App Services&lt;/li&gt;
&lt;li&gt;To Docker containers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On day 15 of my advent calendar I'm showing how to publish to a local IIS.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In &amp;quot;classic&amp;quot; ASP.NET, applications are DLLs that are hosted inside the
IIS Application Pool (also known as Worker Process, &lt;code&gt;w3wp.exe&lt;/code&gt;). They
are instantiated from IIS's runtime manager. When requests come in,
they are sent to the &lt;code&gt;HttpRuntime&lt;/code&gt; of the right site, which lives
inside an AppPool. In short, they are basically modules controlled by
IIS itself.&lt;/p&gt;
&lt;p&gt;In ASP.NET Core, it is totally different. ASP.NET Core applications
(remember, they are all console applications) run their own web server
using Kestrel. Each application already hosts itself and can directly
respond to requests over HTTP, so you might be wondering why you need
IIS in first place.&lt;/p&gt;
&lt;p&gt;In this case IIS basically acts as a reverse proxy, receiving the
requests and forwarding them to the ASP.NET Core application
self-hosted on a Kestrel web server. Then it waits for the execution
pipeline to complete its processing and sends back the HTTP output to
the originator of the request.&lt;/p&gt;
&lt;p&gt;This is accomplished by &lt;code&gt;AspNetCoreModule&lt;/code&gt;, which calls the &lt;code&gt;dotnet
run&lt;/code&gt; command to fire up the application the first time it is
requested.&lt;/p&gt;
&lt;p&gt;This module is configured via the &lt;code&gt;web.config&lt;/code&gt; file in the root of the
application.&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt; &lt;configuration&gt;&lt;br /&gt;
&amp;lt;system.webServer&amp;gt;
    &lt;handlers&gt;
      &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /&gt;
    &lt;/handlers&gt;
    &lt;aspNetCore processPath="dotnet" arguments=".\PublishSample.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /&gt;&lt;br /&gt;
&amp;lt;/system.webServer&amp;gt; &lt;/configuration&gt;&lt;/p&gt;
&lt;p&gt;But you don't have to worry too much about this &lt;code&gt;web.config&lt;/code&gt; since
it's automatically generated, together with the compiled DLLs and
other configuration files, when you run the &lt;code&gt;dotnet publish&lt;/code&gt; command.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1027/publish_artifacts.png" alt="enter image description here" /&gt;&lt;/p&gt;
&lt;p&gt;Now rarely people still deploy to servers on premise, so tomorrow I'm going to show how deploying to Azure. &lt;a href="http://codeclimber.net.nz/"&gt;Come back to my blog to read more&lt;/a&gt;, and to read more about deploying applications on IIS and Azure, please consider &lt;a href="http://amzn.to/2hDX37c"&gt;pre-ordering my book&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To know more about what I'm publishing, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/simonech"&gt;follow me on twitter&lt;/a&gt; or &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;like the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Fri, 15 Dec 2017 10:54:35 Z</pubDate>
      <a10:updated>2017-12-15T10:54:35Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3360</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/14/introduction-to-webpack-day-14-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>Introduction to webpack - Day 14 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;What is webpack? Why is it listed as part of my chapter on build automation systems? Let's find it out in this extract from chapter 6 of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;webpack is a &lt;em&gt;module bundler&lt;/em&gt; that loads all the dependencies of a
JavaScript application and bundles them to optimize the loading time
in the browser. Although it is not strictly speaking a task runner,
webpack can be used to accomplish most of the tasks performed by Gulp,
like minification, bundling, and linting. Let’s see how this works.&lt;/p&gt;
&lt;h2&gt;webpack’s main concepts&lt;/h2&gt;
&lt;p&gt;webpack has a bit steeper learning curve compared to Gulp, so before seeing some examples, let’s have a look at
the main concepts: &lt;em&gt;entry&lt;/em&gt;, &lt;em&gt;output&lt;/em&gt;, &lt;em&gt;loaders&lt;/em&gt;, and &lt;em&gt;plugins&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;It all starts with the &lt;em&gt;entry&lt;/em&gt; point of the application, which is
where webpack starts to follow the dependencies tree from. The end of
the process is the &lt;em&gt;output&lt;/em&gt;, which is where webpack will save the
bundle once it has completed its job. Between the entry and the
output, all the processing happens, which is done by &lt;em&gt;loaders&lt;/em&gt; and
&lt;em&gt;plugins&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;webpack is a JavaScript module bundler, which means that it discovers
JavaScript modules and their dependencies and bundles them. However,
webpack can also treat .css files, sass files, TypeScript files, and
even images and .html files. &lt;strong&gt;Loaders&lt;/strong&gt; are used to “convert” any
kind of file in a module treatable by webpack. &lt;strong&gt;Plugins&lt;/strong&gt; do not work
on the individual source files but are used to perform general
operations on the final output of the bundling.&lt;/p&gt;
&lt;p&gt;The configuration of webpack is stored in a &lt;code&gt;webpack.config.js&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;For example, the following configuration bundles all JavaScript files
of the application (or at least the ones &amp;quot;reachable&amp;quot; from the entry
point via ECMAScript 5 export/import of modules)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;var path = require(‘path’);

module.exports = {
  entry: ‘./src/index.js’,
  output: {
    filename: ‘bundle.js’,
    path: path.resolve(__dirname, ‘dist’)
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;
&lt;p&gt;The book covers the usage of webpack more in details. If you are interested, please &lt;a href="http://amzn.to/2hDX37c"&gt;consider pre-ordering my book&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Tomorrow I'm going to cover installation of ASP.NET Core on on-prem IIS. If you are interested, don't forget to &lt;a href="http://codeclimber.net.nz/"&gt;check my blog again&lt;/a&gt;, &lt;a href="http://feeds.feedburner.com/codeclimber"&gt;subscribe to my RSS feed&lt;/a&gt;, &lt;a href="https://twitter.com/Simonech"&gt;follow me on twitter&lt;/a&gt; or like &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;the Facebook page of my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Thu, 14 Dec 2017 10:04:34 Z</pubDate>
      <a10:updated>2017-12-14T10:04:34Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3359</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/13/what-is-the-role-of-build-systems-in-front-end-development-day-13-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>What is the role of build systems in front-end development - Day 13 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;With JavaScript frameworks becoming more and more complicate, and with the increasing demand for performances also on the client-side of applications, gone are the days when it was just enough to put some javascript or css files in a static folder. Today, 13 days into the advent calendar of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;,&lt;/a&gt; I'm going to share an extract of chapter 6, which introduces the role build systems in front-end development.&lt;/p&gt;
&lt;blockquote&gt;
&lt;h2&gt;What Front-End Build Systems are for&lt;/h2&gt;
&lt;p&gt;In the context of server-side compiled languages, build systems are
used to compile code into binaries, to run tests, to compute metrics,
and to perform transformations of configuration files from development
to a production setup. Other typical operations include moving files
around and creating release files. Front-end build systems are also
used for more or less the same reasons as server-side build systems
because even front-end development requires &amp;quot;compiling&amp;quot; code files
into &amp;quot;binaries&amp;quot; (for example Less or Sass to CSS or TypeScript to
JavaScript) or running JavaScript test suites or metrics (JSLint for
example). However, front-end development also requires some tasks that
are specific to JavaScript and CSS development and that are used
during the development phase and not just during the final release.
One such task is automatically including references to Bower files.
Another example is minification and concatenation of JavaScript and
CSS files to reduce the size and number of files downloaded by the
client.&lt;/p&gt;
&lt;p&gt;The rest of the chapter explains how to perform some of the most
common tasks. It will show how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Automatically include references to Bower packages&lt;/li&gt;
&lt;li&gt;Compile Sass files to CSS&lt;/li&gt;
&lt;li&gt;Compile TypeScript to JavaScript&lt;/li&gt;
&lt;li&gt;Combine and minify JavaScript and CSS files&lt;/li&gt;
&lt;li&gt;Run JSLint to detect JavaScript problems&lt;/li&gt;
&lt;li&gt;Perform tasks and automatically reload the browser when changes are detected in a file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The tool used to show how to perform these tasks is Gulp, since it is
the tool the .NET community is mostly leaning toward. Later in the
chapter there is also a quick introduction to webpack, which was
already briefly mentioned in Chapter 3 since it is used by the Angular
Command Line tool and is gaining a lot of traction in the front-end
development community.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Tomorrow I'll give a quick introduction to webpack, so &lt;a href="http://codeclimber.net.nz/"&gt;come back for more&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are liking this series of posts, please consider pre-ordering &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;, from which all these extracts are taken, and cover all of these topics more in details.&lt;/p&gt;
</description>
      <pubDate>Wed, 13 Dec 2017 11:03:55 Z</pubDate>
      <a10:updated>2017-12-13T11:03:55Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3358</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/12/how-to-publish-your-own-nuget-package-day-12-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>How to publish your own Nuget Package - Day 12 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;With package managers you consume libraries but eventually you will end up releasing yours for others to use, either to the community or as shared among co-workers. Today we look into how to do it with Nuget and .NET Core.&lt;/p&gt;
&lt;p&gt;Doing a Nuget package was a bit convoluted with the traditional .NET Framework, but with .NET Core it's very easy.&lt;/p&gt;
&lt;h2&gt;Add metadata&lt;/h2&gt;
&lt;p&gt;After having developed the application, just add to your &lt;code&gt;.csproj&lt;/code&gt; file the metadata needed (no need for a specific &lt;code&gt;.nuspec&lt;/code&gt;).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;Project Sdk=&amp;quot;Microsoft.NET.Sdk&amp;quot;&amp;gt;
  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;TargetFramework&amp;gt;netcoreapp2.0&amp;lt;/TargetFramework&amp;gt;
    &amp;lt;PackageId&amp;gt;Wrox.Book&amp;lt;/PackageId&amp;gt;
    &amp;lt;PackageVersion&amp;gt;1.0.0&amp;lt;/PackageVersion&amp;gt;
    &amp;lt;Authors&amp;gt;Simone Chiaretta&amp;lt;/Authors&amp;gt;
    &amp;lt;Description&amp;gt;Show the title of the book&amp;lt;/Description&amp;gt;
    &amp;lt;PackageReleaseNotes&amp;gt;First release&amp;lt;/PackageReleaseNotes&amp;gt;
    &amp;lt;Copyright&amp;gt;Copyright 2017 (c) Simone Chiaretta&amp;lt;/Copyright&amp;gt;
    &amp;lt;PackageTags&amp;gt;book title Wrox&amp;lt;/PackageTags&amp;gt;
    &amp;lt;PackageProjectUrl&amp;gt;http://example.com/Wrox.Book/&amp;lt;/PackageProjectUrl&amp;gt;
    &amp;lt;PackageIconUrl&amp;gt;http://example.com/Wrox.Book/32x32icon.png&amp;lt;/PackageIconUrl&amp;gt;
    &amp;lt;PackageLicenseUrl&amp;gt;http://example.com/Wrox.Book/mylicense.html&amp;lt;/PackageLicenseUrl&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;
&amp;lt;/Project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Create the package&lt;/h2&gt;
&lt;p&gt;Now just go to the root of the project (where the &lt;code&gt;.csproj&lt;/code&gt; is) and type &lt;code&gt;dotnet pack -c Release&lt;/code&gt;. This will build the project and create a nuget package file, saved in &lt;code&gt;bin\Release&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you now open the file with the &lt;a href="https://github.com/NuGetPackageExplorer/NuGetPackageExplorer"&gt;Nuget Package Explorer&lt;/a&gt; you'll see the content of the file&lt;/p&gt;
&lt;p&gt;&lt;img src="http://codeclimber.net.nz/media/1023/package-explorer.png" alt="Nuget Package Explorer" /&gt;&lt;/p&gt;
&lt;h2&gt;Publish the package&lt;/h2&gt;
&lt;p&gt;Now you can just either copy the file to a local repository or publish it to the Nuget public repository. To do so:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Download the NuGet command line utility (the dotnet cli is not enough here). You can install it via Nuget as well: &lt;code&gt;Install-Package NuGet.CommandLine&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Create an account on the NuGet.org gallery (if you don't have one)&lt;/li&gt;
&lt;li&gt;Set your API-KEY: &lt;code&gt;nuget setApiKey Your-API-Key&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Publish the package: &lt;code&gt;nuget push YourPackage.nupkg&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This topic is covered more in details, together with how to develop packages for NPM and bower, on &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;. If want to read more extracts of the book, come and &lt;a href="http://codeclimber.net.nz/"&gt;visit my blog again tomorrow&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Tue, 12 Dec 2017 15:50:25 Z</pubDate>
      <a10:updated>2017-12-12T15:50:25Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">3356</guid>
      <link>http://codeclimber.net.nz/archive/2017/12/11/what-are-package-managers-and-why-we-need-them-day-11-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/</link>
      <title>What are package managers and why we need them - Day 11 - 24 days of "Front-end Development with ASP.NET Core, Angular, and Bootstrap"</title>
      <description>&lt;p&gt;Over the weekend I wrote about the &lt;a href="http://codeclimber.net.nz/archive/2017/12/09/bootstrap-responsive-grid-system-day-9-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Bootstrap grid system&lt;/a&gt; and the &lt;a href="http://codeclimber.net.nz/archive/2017/12/10/bootstrap-snippet-pack-for-visual-studio-day-10-24-days-of-front-end-development-with-aspnet-core-angular-and-bootstrap/"&gt;Bootstrap Snippet Pack for Visual Studio&lt;/a&gt;, both extracts from Chapter 4 of &lt;a href="http://amzn.to/2hDX37c"&gt;my upcoming book &amp;quot;Front-end Development with ASP.NET Core, Angular, and Bootstrap&amp;quot;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Today I'm going to cross halfway point in my book, taking a extract from chapter 5, which is about package managers and Nuget, NPM, Bower. And I'm going to introduce package managers and why we need them.&lt;/p&gt;
&lt;blockquote&gt;
&lt;h2&gt;Why we need package managers&lt;/h2&gt;
&lt;p&gt;Modern software development, both front-end and server-side, is based
on small and very focused components that can be composed as needed.&lt;/p&gt;
&lt;p&gt;While it is good to avoid the monolithic frameworks of the past, this
new approach introduces a problem: how do you manage all these
components? Components usually depend on other components, which
depend on yet other components, which depend... well, you got the
idea. To make things more difficult, there might be a component, let's
call it &lt;strong&gt;A&lt;/strong&gt;, that depends on component &lt;strong&gt;B&lt;/strong&gt;, but also another
component, &lt;strong&gt;C&lt;/strong&gt;, that also depends on &lt;strong&gt;B&lt;/strong&gt;, but a different version
of it. And on top of this, all components must be kept up-to-date.
Finally, in some cases, to correctly install a component, additional
operations might be needed, like compiling some native library or
changing some configuration files.&lt;/p&gt;
&lt;p&gt;Fortunately, all these tasks are automated by specific tools that are
called &lt;em&gt;package managers&lt;/em&gt;. &lt;/p&gt;
&lt;h2&gt;What package managers do&lt;/h2&gt;
&lt;p&gt;All package managers, apart from the obvious differences given by the
different technologies or languages they target, are practically
identical. Here are their common concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They all rely on a public registry that contains all published packages. The registry might also store the actual package or just
provide the URL where the package can be downloaded.&lt;/li&gt;
&lt;li&gt;Packages are downloaded and stored in a local folder (usually within the current user folder) that acts as a local cache. This way
when a project needs a package that has been already downloaded, it's
directly copied from the cache instead of being downloaded again
(providing that it is the latest version). This saves bandwidth and
time (especially if packages are restored every time a project is
built). It also allows some kind of offline development experience
that would be otherwise impossible.&lt;/li&gt;
&lt;li&gt;Projects declare which third-party libraries they depend on. This is usually done by specifying in a JSON file the names of the packages
and their versions.&lt;/li&gt;
&lt;li&gt;Package managers take care of downloading not only the projects’ dependencies but also the libraries they depend on, descending the
entire tree of packages.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;There are still lots of interesting topics coming up from &lt;a href="http://amzn.to/2hDX37c"&gt;my book&lt;/a&gt;. If you are interested &lt;a href="http://codeclimber.net.nz/tags/24days2017"&gt;in knowing more&lt;/a&gt;, &lt;a href="http://codeclimber.net.nz/"&gt;come back&lt;/a&gt; tomorrow and also remember to follow me on &lt;a href="https://twitter.com/Simonech"&gt;Twitter @simonech&lt;/a&gt; and like the &lt;a href="https://www.facebook.com/aspnetcorefrontend/"&gt;Facebook page for my book&lt;/a&gt;.&lt;/p&gt;
</description>
      <pubDate>Mon, 11 Dec 2017 11:51:16 Z</pubDate>
      <a10:updated>2017-12-11T11:51:16Z</a10:updated>
    </item>
  </channel>
</rss>