dotnet / dotnet/templating

.NET new install <local-path> exiting with status code 0 on error

Open
#8,200 1 comment 0 reactions 0 assignees View on GitHub
triage:transfer-to-sdk
Dominant language
No language data
Stars
1.7k
Forks
399
Avg merge
3d 5h
Merged PRs (30d)
39

Description

### Product

dotnet CLI (dotnet new)

### Describe The Bug

I want to test if my templates are valid in CI/CD. I thought i could install the template in the workflow and it would fail if there are any errors. It turns out that even if there are errors with the template, the exit code is still 0.

### To Reproduce

Steps:
1. Create a new template
2. malform template.config
3. install template
4. check exit code

```
$ dotnet new install content/WPF
[20]The following template packages will be installed:
[21]/templates/dotnet/content/WPF
[22]Error: The template 'WPF-Template' (Template.Dotnet.WPF) has the following validation errors:
[23][Error][MV012] Source location '../doesnotexist/' is outside the specified install source location.
[24]Error: Failed to load the template 'WPF-Template' (Template.Dotnet.WPF): the template is not valid.
[26]No templates were found in the package /templates/dotnet/content/WPF.
[27]$ echo $?
[28]0
```

### dotnet Info

output
.NET SDK:
Version: 8.0.301
Commit: 1a0e9c0300
Workload version: 8.0.300-manifests.f6879a9a
MSBuild version: 17.10.4+10fbfbf2e

Laufzeitumgebung:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.301\

Installierte .NET-Workloads:
Es sind keine installierten Workloads zum Anzeigen vorhanden.

Host:
Version: 8.0.6
Architecture: x64
Commit: 3b8b000a0e

.NET SDKs installed:
6.0.300 [C:\Program Files\dotnet\sdk]
6.0.321 [C:\Program Files\dotnet\sdk]
8.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download


### Visual Studio Version

_No response_

### Additional context

_No response_

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.