Using WinGet Configure to install your .NET environment quickly

Posted: (EET/GMT+2)

 

Installing a new development machine or a virtual machine (VM) from scratch is a tedious process. Various tools have been developed for this in the "DevOps" style of thinking, but now that Microsoft made "winget configure" available broadly, it's something you can use to install (and configure) various tools quickly.

WinGet configuration files use YAML to describe a list of things you need, and the WinGet tool itself will make sure you environment (physical or virtual) will match. If you store those files with the ".winget" file extension, you could just double-click those files, and automatic installation would follow. Very neat.

Case in point, look at this URL:

https://builds.dotnet.microsoft.com/dotnet/install/dotnet_basic_config_docs.winget

If you download this file, it will contain YAML script as follows:

# This configuration file installs the .NET 10 SDK, VS Code, and C# Dev Kit for .NET docs.
properties:
  resources:
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: install-dotnet10-SDK
      directives:
        description: Install .NET 10 SDK
        securityContext: elevated
      settings:
        id: Microsoft.DotNet.SDK.10
        source: winget
        useLatest: true
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: install-vs-code
      directives:
        description: Install Visual Studio Code
      settings:
        id: Microsoft.VisualStudioCode
        source: winget
        useLatest: true
    - resource: Microsoft.VSCode.DSC/VSCodeExtension
      id: install-csharp-dev-kit
      dependsOn:
        - install-vs-code
      directives:
        description: Install C# Dev Kit
        allowPrerelease: true
      settings:
        name: ms-dotnettools.csdevkit
        exist: true
  configurationVersion: 0.2.0

This about 30-line YAML file will install three things: the .NET 10 SDK, Visual Studio Code, and the C# DevKit extension. Of course, this is not yet Visual Studio, but at least a start for .NET/C# development work.

Installing those manually takes maybe 10 minutes, but with this script, perhaps 10 seconds.

Next, I need to start thinking what else I might install automatically with this.