Search code examples
.netpowershellchocolatey

Install dotnet sdk latest release of a specific major Version


I have a task of installing latest 6.x.x version of dotnet-sdk on powershell. We are currently using chocolatey to install the pinned sdk version but chocolatey doesnt suppport wildcards.

Current Code :

choco install dotnet-sdk --version 6.0.302

I have to install latest release from version 6.

I referred to this page https://dotnet.microsoft.com/en-us/download/dotnet/6.0 but couldnt convert the installation to script.


Solution

  • If you really want to use Chocolatey, install the dotnet-6.0-sdk package without a version :

    choco install dotnet-6.0-sdk
    

    As the docs explain:

    This is a metapackage, which installs the latest release of .NET 6.0 SDK across all feature updates.

    .NET SDK isn't deployed through Chocolatey. What you find there is a metapackage that downloads and installs the actual installation package. The maintainers of those packages ensured there's both an overall package, dotnet-sdk and packages specific to major versions like dotnet-6.0-sdk. Every time a new SDK is released, the maintainers update the packages.

    Another option is to download and use the official .NET installation scripts. There's always a link in the .NET SDK download page, that links to the script download page and the documentation If you don't need Chocolatey, you can use the Powershell .NET installation scripts found in the .NET download page.