Posts

Showing posts from November, 2020

Build your cross-platform, natively executable web app in 3 minutes! #dotnetconf

Image
 Much kudos to John Juback (@jjuback) You'll need Visual Studio Code In a console/terminal window, type mkdir Processes cd Processes dotnet new webapp code . In Processes.csproj, add   <ItemGroup>     <PackageReference       Include="ElectronNET.API"       Version="9.31.2"/>   </ItemGroup> In Program.cs, add   using ElectronNET.API; on line 9                     webBuilder.UseElectron(args);                     webBuilder.UseEnvironment("Development"); on line 24 In Startup.cs, add   using ElectronNET.API; on line 11             if (HybridSupport.IsElectronActive) {                 CreateWindow();             }    on line 56         private async void CreateWindow() {             var window = await Electron.WindowManager.CreateWindowAsync();             window.OnClosed += () => {                 Electron.App.Quit();             };         } on line 61 In Visual Studio Code's terminal window, run dotnet tool install ElectronNET

API versioning with ASP.NET MVC Core and NSwag

Image
We support versioning in theory, but we've never really left v1.0 If this is a quote that resonates with you, read on. Our team added our first v2.0 endpoint in one of our products by doing the following: Removing [ApiVersionNeutral] on the endpoints that we didn't want versioned (as opposed to being available on any version of the API). Configuring ASP.NET to assume neutral if unspecified: services. AddApiVersioning ( o => { o. UseApiBehavior = true ; o. DefaultApiVersion = ApiVersion . Neutral ; o. AssumeDefaultVersionWhenUnspecified = true ; Removing our [ApiVersion("1.0")] on our base controllers Decorating our old methods with [ApiVersion("1.0")] Decorating our new methods with [ApiVersion("2.0")] It took some trial and error, as we presumed that we could just add [ApiVersion("2.0")] on our new stuff and be done with it. This made NSwag registering the endpoints multiple times, ho

Remove local git branches on Windows with PowerShell

Image
There is plenty of tooling and scripts for *nix systems  to delete local branches, but I was struggling to find useful snippets for Windows, so I made one. Remove-LocalBranches is available as a script on GitHub for you to download and modify to your heart's content. It removes non-active branches from a set of directories and is designed to be run as an atomic unit (doesn't accept input). The script is dependent on another utility script I wrote that enters a directory, runs a script block and then returns to where it were. That script is also available on GitHub. So, to answer "how do I remove unused / old local branches", the answer is "Run Remove-LocalBranches.ps1". I hope this is useful :)  Example run: