Improve PowerShell performance by disabling progress bars

 
 
  • Gérald Barré
Some commands in PowerShell display progress bars. For instance, Invoke-WebRequest displays the download progression. These progress bars can slow down the execution of the commands as writing to the console takes time. If you don't need the progress bars, you can disable them to improve the performance of your scripts. Note that recent versions of PowerShell Core (7.x) have a better performance than… [read more]

Sharing the Renovate configuration across multiple projects

 
 
  • Gérald Barré
Renovate is a tool that helps you to keep your dependencies up-to-date. You can configure Renovate using a configuration file at the root of the repository. In this post, I describe how to share the Renovate configuration across multiple projects. Developers don't like to maintain the same configuration in multiple repositories. It's error-prone and time-consuming. By sharing the configuration, you can… [read more]

Create a multi-arch Docker image for a .NET application

 
 
  • Gérald Barré
We are in a transition period where x64 architectures are not the only architectures available. Apple has switched to ARM with the M1 chip, and Microsoft is also pushing for ARM now. If you want to run your application on ARM64 and x64 architectures, you need to create a Docker image for each architecture. Docker supports multi-arch images, which allow you to create a single image that can run on multiple… [read more]

How to avoid conflicts when testing your dotnet templates locally

 
 
  • Gérald Barré
When you author a dotnet template, you can use the dotnet install and dotnet new commands to create a new project based on your local template. However, dotnet install may conflict with a previous installation of the template published as a NuGet package. In this post, I describe how to avoid this conflict and how to test your template locally. dotnet has a few hidden arguments that you can use to debug… [read more]

How to check if a DLL and an exe is a .NET assembly

 
 
  • Gérald Barré
Recently, I needed to check if a file was a .NET assembly without loading the assembly. .NET uses the Portable Executable (PE) format to store assemblies. The PE format is a file format for executables or DLLs on Windows, but .NET also uses it on Linux and MacOS. Hopefully, .NET provides the PEReader class to read the file header. This class can parse the content of a file to extract PE information. You… [read more]

How to use the latest target framework available for a .NET SDK

 
 
  • Gérald Barré
Sometimes, you don't want to bother with the target framework version of your project. You just want to use the latest version available from the .NET SDK. This can be useful if you want to always be on the latest version and don't want to spend time updating the .csproj files. You can fix the version of the SDK in a global.json file and use tools such as Renovate to update the version of the SDK for you.… [read more]

Using type aliases to make code clearer with generics

 
 
  • Gérald Barré
When you use generic types in C#, it is sometimes hard to understand what the generic argument can represent. For example, what do the strings represent in Dictionary<string, string>? To make the code clearer, you can use type aliases. // ❌ What does the string means? _ = new Dictionary<string, string>(); // Create aliases using UserId = string; using ProjectId = string; // Use the type aliases // ✅ It's… [read more]