How to deploy a Nuget package that provides a Powershell command like EF's Scaffold-DbContext? How to deploy a Nuget package that provides a Powershell command like EF's Scaffold-DbContext? powershell powershell

How to deploy a Nuget package that provides a Powershell command like EF's Scaffold-DbContext?


If I understand you right you want to implement this use case:

"On nuget package install I want to start a ps script that parse project sources and crate new genereated files"?

You can't emulate TT script delivery this way because TT is the thing that is already installed as VS extension (and is integrated to VS).

TT script delivery through NUGET was simple because on install it was required just to put tt file to the project folder.

For advanced scenarios you would need a custom dotnet tooling command https://docs.microsoft.com/en-us/dotnet/core/tools/extensibilityor VS Extension or both.


Last time I worked with it, (which was a few years back) the init.ps1 file was just a powershell script that runs inside visual studio inside your project context when you install the package. I assume that EF is complicated enough that it needs the binaries, but you can use all the regular powershell cmdlets to manipulate the project:

Think New-Item , Copy-Item, Get-ChildItem, Test-Path, Add-Contentetc.

Take a look here https://docs.microsoft.com/en-gb/powershell/module/Microsoft.PowerShell.Management/?view=powershell-6 for more commands.