Description
Describe the bug
The .NET template engine fails to execute post-creation actions defined in a template.json
file. The error message consistently reports "Failed to run the command: argument 'executable' is missing in post action configuration," even when the executable
property is explicitly defined in the postActions
section of the template.json
. This occurs with both custom bash scripts and built-in commands like echo
.
To Reproduce
-
Create a new empty folder, e.g.,
TestTemplate
. -
Inside
TestTemplate
, create a folder.template.config
. -
Inside
.template.config
, create a file namedtemplate.json
with the following content:{ "$schema": "[http://json.schemastore.org/template](http://json.schemastore.org/template)", "identity": "Test.PostAction", "name": "Test Post Action", "shortName": "test-post", "sources": [ { "source": "./content" } ], "postActions": [ { "actionId": "testAction", "description": "Run echo command", "manualInstructions": [], "executable": "echo", "script": "Hello from minimal post-action!", "continueOnError": true } ] }
-
Inside
TestTemplate
, create an empty folder namedcontent
. -
Navigate to the
TestTemplate
directory in your terminal (e.g., PowerShell, Command Prompt, Git Bash). -
Install the template:
dotnet new install .
-
Navigate to a different directory.
-
Create a new project using the template:
dotnet new test-post -o TestOutput
-
When prompted to run the post-creation action, select
y
.
Alternatively, you can reproduce the bug with the following repository: https://github.com/ulfbou/Zentient.Templates/tree/master/templates/CleanArch
Exceptions (if any)
The following error message is displayed in the terminal after selecting 'y' to run the post-creation action:
Failed to run the command: argument 'executable' is missing in post action configuration.Post action failed.
No other exceptions or stack traces are provided.
Further technical details
-
Operating System: Windows 10 PRO
-
.NET SDK Version(s) Tested: 8.0.408 and 9.0.203
-
IDE: Visual Studio Community 2022 17.13.6
-
Are you using a
global.json
file? Yes, to explicitly target SDK 8.0.408 during one of the test attempts. The issue was also observed without aglobal.json
when the active SDK was 9.0.203. -
Have you tried a system reboot? Yes, the issue persists after a reboot.
-
Have you checked environment variables for potential conflicts? Yes, no obvious conflicts related to command execution were found.
-
Have you temporarily disabled antivirus software? Yes, the issue persists with antivirus temporarily disabled.
-
Output of
dotnet --info
:.NET SDK: Version: 9.0.203 Commit: dc7acfa194 Workload version: 9.0.200-manifests.12d79ccf MSBuild version: 17.13.20+a4ef1e90f Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\9.0.203\ .NET workloads installed: There are no installed workloads to display. Configured to use loose manifests when installing new manifests. Host: Version: 9.0.4 Architecture: x64 Commit: f57e6dc747 .NET SDKs installed: 8.0.408 [C:\Program Files\dotnet\sdk] 9.0.203 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 8.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 9.0.4 [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](https://aka.ms/dotnet/info) Download .NET: [https://aka.ms/dotnet/download](https://aka.ms/dotnet/download)