dotnet/templating

Custom Template auto restore not working no matter what

TheExiledCat opened this issue · 0 comments

Product

dotnet CLI (dotnet new)

Describe The Bug

the dotnet restore post action in template.json is not being called, causing the user to have to manually restore after using dotnet new

To Reproduce

Steps:

  1. create a simple console app
  2. add a template.json like this:
{
  "$schema": "http://json.schemastore.org/template",
  "author": "TheExiledCat",
  "classifications": [ "Common", "Console" ],
  "identity": "SimpleRestApi.Empty",
  "name": "SimpleRestApi Empty project",
  "shortName": "simplerest.empty",
  "sourceName": "SimpleRestApp",
  "tags": {
    "language": "C#",
    "type": "project",  
    "frameworkType": "api"
  },

"postActions": [{
  "condition": "(!skipRestore)",
  "description": "Restore NuGet packages required by this project.",
  "manualInstructions": [{
    "text": "Run 'dotnet restore'"
  }],
  "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
  "continueOnError": false
}]
}
  1. install the template and create a new app with dotnet new simplerest.empty

dotnet Info

output .NET SDK: Version: 8.0.108 Commit: 665a05cea7 Workload version: 8.0.100-manifests.109ff937

Runtime Environment:
OS Name: linuxmint
OS Version: 21.3
OS Platform: Linux
RID: ubuntu.22.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.108/

.NET workloads installed:
Workload version: 8.0.100-manifests.109ff937
There are no installed workloads to display.

Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5

.NET SDKs installed:
8.0.108 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

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

N/A

Additional context

The dotnet new command doesnt create any errors, it just created the project as expected but it doesnt restore anything, meaning the references dont get installed and the used has to manually restore.

i tried multiple template.jsons including one with primaryOutputs but it didnt work either