|
| 1 | +--- |
| 2 | +title: .NET SDK workload sets |
| 3 | +description: "Learn how to use workload sets to control which versions of workloads get installed, updated, and restored." |
| 4 | +author: tdykstra |
| 5 | +ms.author: tdykstra |
| 6 | +ms.service: dotnet |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 08/02/2024 |
| 9 | + |
| 10 | +#customer intent: As a developer using multiple workloads in a project, I want to keep my workload versions in sync so that I can avoid problems that might arise from conflicts betwween versions. Even if I only have one workload, I want to avoid having a workload be updated to a different version when I'm not expecting it. |
| 11 | +--- |
| 12 | +# .NET SDK workload sets |
| 13 | + |
| 14 | +A workload set provides a single version number that represents a group of .NET SDK workloads. This enables you to install and update a combination of workload versions that ship at the same time and are known to work together. Workload sets are published to nuget.org with each release of the .NET SDK, under the package ID `Microsoft.NET.Workloads.<feature band>` |
| 15 | + |
| 16 | +Here are some ways you can use workload sets: |
| 17 | + |
| 18 | +* Update to the latest available workload set version. |
| 19 | +* Update to a specific workload set version. |
| 20 | +* "Pin" the install command to a specific workload set version. |
| 21 | +* Restore to a specific workload set version. |
| 22 | + |
| 23 | +You can also: |
| 24 | + |
| 25 | +* Check a project's current workload set version. |
| 26 | +* Update to the latest version of each individual workload, ignoring workload sets. |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +* [.NET 8.0.400 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) or later. |
| 31 | + |
| 32 | + In 8.0.400 SDK, the `dotnet workload` commands are in workload set update mode when it's explicitly selected. In [.NET 9 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0), `dotnet workload` commands are in workload set update mode by default. |
| 33 | + |
| 34 | +## Update to the latest available workload set version |
| 35 | + |
| 36 | +To update installed workloads to the latest workload set version available on the configured feeds, run these commands: |
| 37 | + |
| 38 | +```dotnetcli |
| 39 | +dotnet workload config --update-mode workload-set |
| 40 | +dotnet workload update |
| 41 | +``` |
| 42 | + |
| 43 | +In .NET 9 SDK, workload set update mode is the default, so it isn't necessary to explicitly select it with the `dotnet workload config` command shown here. |
| 44 | + |
| 45 | +## Update to a specific workload set version |
| 46 | + |
| 47 | +Use the `--version` option of the `dotnet workload update` command to specify a workload set version to update to. For example: |
| 48 | + |
| 49 | +```dotnetcli |
| 50 | +dotnet workload update --version 8.400.0-preview.0.24219.1. |
| 51 | +``` |
| 52 | + |
| 53 | +## "Pin" the install command |
| 54 | + |
| 55 | +A `dotnet workload install` command with the `--version` option "pins" the `dotnet workload install` command so that it no longer automatically installs a newer workload set. However, `dotnet workload update` doesn't get pinned. If you run a `dotnet workload update` command without the `--version` option, the command: |
| 56 | + |
| 57 | +* Installs the latest available workload set version. |
| 58 | +* "Unpins" the `install` command. |
| 59 | +* Stays in workload set update mode. |
| 60 | + |
| 61 | +## Specify the workload set version using global.json |
| 62 | + |
| 63 | +Create a `global.json` file to specify the workload set version for a repository. The format looks like this example: |
| 64 | + |
| 65 | +```json |
| 66 | +{ |
| 67 | + "sdk": { |
| 68 | + "workloadVersion": "8.400.0-preview.0.24219.1" |
| 69 | + } |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +With the current directory in the same repository, `dotnet workload restore` installs workloads for the specified workload set version. If you don't have a global.json file, and you're in workload set update mode, the `restore` command will install the workload set version that was established when you switched from manifests update mode to workload sets update mode. |
| 74 | + |
| 75 | +## Ignore workload set versions |
| 76 | + |
| 77 | +To update to the latest version of each individual workload available on the configured feeds, select and use manifests update mode by running these commands: |
| 78 | + |
| 79 | +```dotnetcli |
| 80 | +dotnet workload config --update-mode manifests |
| 81 | +dotnet workload update |
| 82 | +``` |
| 83 | + |
| 84 | +In .NET 8.0.4xx SDK, manifests mode is the default. You need to select manifests mode explicitly only if you explicitly selected workload set update mode. |
| 85 | + |
| 86 | +## Check the workload set version |
| 87 | + |
| 88 | +To see the current workload set version, run `dotnet workload --version`. If a workload set is installed, you see a version such as `8.0.400-preview.0.24217.2` or `8.0.401`. If there is no workload set version, you see a version in the form of `<feature band>-manifests.<hash>`, such as `8.0.400-manifests.45f976f0`. |
| 89 | + |
| 90 | +## Related content |
| 91 | + |
| 92 | +[dotnet workload command](dotnet-workload.md) |
| 93 | +[dotnet workload install](dotnet-workload-install.md) |
| 94 | +[dotnet workload update](dotnet-workload-update.md) |
0 commit comments