dotnet / dotnet/sdk

`dotnet new --no-update-check` does not suppress Optional workloads provider notice

Open
#55,386 2 comments 1 reaction 3 assignees Claimed by @nagilson View on GitHub
Area-dotnet new cookie
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Description

`dotnet new` still prints a template update notice from the `Optional workloads` provider when `--no-update-check` is specified.

The notice is also confusing because it names the candidate built-in package version, rather than the currently selected manually installed version:

```text
An update for template package 'Microsoft.Maui.Templates.net11@11.0.0-preview.6.26360.8' is available in the 'Optional workloads' provider.
To use built-in template package, uninstall manually installed template package using:
dotnet new uninstall Microsoft.Maui.Templates.net11
```

The command succeeds with exit code 0, but this looks like an error/update warning even though update checks were explicitly disabled.

### Reproduction

This uses a custom template-engine hive and public NuGet packages, so it does not depend on existing user state:

```powershell
$hive = 'C:\temp\dotnet-new-hive'

# The SDK contains preview.6 as a built-in optional-workload template pack.
dotnet new install Microsoft.Maui.Templates.net11@11.0.0-preview.5.26304.4 `
--force `
--debug:custom-hive $hive

# The provider notice is still printed despite --no-update-check.
dotnet new maui -sc `
--dry-run `
--no-update-check `
--debug:custom-hive $hive
```

The install command is expected to explain that the manually installed package overrides the built-in package. The subsequent create command is where the unexpected notice appears.

A clean custom hive without the manually installed package does not print the notice.

### Expected behavior

`--no-update-check` should suppress all template package update notices, including notices generated from the `Optional workloads` provider.

If this provider message is intentionally not an update check, it should be described differently and identify both versions clearly, for example that the selected manually installed `preview.5` package overrides the built-in `preview.6` package.

### Actual behavior

The create command prints the optional-workload update notice and uninstall guidance even with `--no-update-check`. It identifies `preview.6` as the package for which an update is available, although `preview.5` is the manually installed/selected package.

### Environment

```text
.NET SDK: 11.0.100-preview.6.26359.118
SDK commit: ba53d0ed33
Workload version: 11.0.100-preview.6.26364.2
MSBuild: 18.9.0-preview-26359-118+ba53d0ed3
OS: Windows 10.0.26200, win-x64
```

Relevant installed layout:

```text
C:\Program Files\dotnet\sdk\11.0.100-preview.6.26359.118\
C:\Program Files\dotnet\template-packs\Microsoft.Maui.Templates.net11.11.0.0-preview.6.26360.8.nupkg
```

The SDK registers `OptionalWorkloadProviderFactory` in `src/Cli/dotnet/Commands/New/NewCommandParser.cs`; `OptionalWorkloadProvider` discovers the built-in package through `TemplateLocator`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.