PowerShell.ps1 File in Post Build Visual Studio Event

I am trying to execute the following post build event code, but I am getting an unrealizable error:

"c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -file "$(SolutionDir)tools\nuget_pack.ps1"

I tried the following PS script before trying:

Set-ExecutionPolicy unrestricted

What am I missing?

UPDATE

This is strange, I am not getting an error in VS now. but the script is not working. When I run it with the PowerShell console, I get the following error:

enter image description here

+5
source share
3 answers

You can reproduce the error in Powershell as follows:

"this is a string" -file "my.ps1"

, -file -f , .

:

& "c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "$ (SolutionDir) tools\nuget_pack.ps1"

( , , bat, Powershell.)

:

powershell.exe -file "$(SolutionDir)tools\nuget_pack.ps1"
+7

Visual Studio post-build script .BAT cmd.exe. & "<path-to-powershell>" . :

Powershell.exe -file "$(SolutionDir)tools\nuget_pack.ps1"

, , , , :

Powershell.exe -ExecutionPolicy Unrestricted -file "$(SolutionDir)tools\nuget_pack.ps1" 
+10

power-shell script visual studio ExecutionPolicy , ...

Set-ExecutionPolicy -Scope CurrentUser;
ExecutionPolicy: unrestricted;

shell call script as follows ...

powershell.exe $(SolutionDir)Setup.ps1 -SolutionDir $(SolutionDir) -ProjectPath $(ProjectPath)

enter image description here

then in a script you can always read a parameter like this ...

param([string]$SolutionDir,
     [string]$ProjectPath);
#Write-Host ($SolutionDir +" Call this script with following aruments");
#Write-Host ($ProjectPath +" Call this script with following aruments");
0
source

All Articles