dotnet / templating

This repo contains the Template Engine which is used by dotnet new
https://docs.microsoft.com/dotnet/
MIT License
1.62k stars 369 forks source link

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

Open jankoosk opened 3 months ago

jankoosk commented 3 months ago

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

jankoosk commented 3 months ago

If this is the intended behaviour, how can i check if my templates are valid before publishing them?