Reputation: 932
If I want to run a Powershell script after build in Visual Studio, I can do it like this in the post build event in the project properties:
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -file $(SolutionDir)Powershell\Post-Build.ps1
This is included in the project file, and respected by dotnet build
, so it also works on the command line.
The path of the Powershell binary seems to be guaranteed on all Windows systems that includes Powershell, so the absolute path of PS is not an issue.
This is all great. But how would I rewrite the reference to the powershell
bin so it works cross platform? Is there a way to resolve the path of the PS binary, utilizing PS Core (pwsh
) on non-Windows platforms?
Upvotes: 0
Views: 525
Reputation: 21418
As close as they may be, PowerShell Core is not a 1:1 match for functionality with Windows PowerShell. PowerShell Core is PowerShell 6+ while Windows PowerShell is 5.1 and earlier. If you want a cross platform solution, the correct answer here is to go with PowerShell Core as your standard PowerShell version, and make sure that it's installed as a dependency on both your Windows and Linux nodes.
Upvotes: 1