Blog

Quick Tip: How to run powershell script after 'dotnet new'

September 12, 2018 | 0 Minute Read

This quick tip is about how to run a powershell script after the template is created.

I like the new templating engine. It has already a lot of features and they work well.

It is possible to run any external command after the template is created with the built-in action. The key difference is to set the powershell as executable and pass the script with the parameter -File.

"postActions": [{
         {
          "description ": "Runs the ... script.",
          "manualInstructions": [{ 
            "text": "Run 'filename.ps1'" 
            }],
          "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
          "args": {
            "executable": "powershell",
            "args": "-File filename.ps1"
          },
          "continueOnError": true
        }
    }]