Post build event execute PowerShell

后端 未结 5 1137
南旧
南旧 2020-11-27 12:04

Is it possible to set up a .NET project with a post build event to execute a powershell script? I am using this script to generate some files.

Also can I pass whethe

5条回答
  •  伪装坚强ぢ
    2020-11-27 12:41

    Before calling power-shell script from visual studio, set the ExecutionPolicy to RemoteSigned from power-shell window like this...

    Set-ExecutionPolicy -Scope CurrentUser;
    ExecutionPolicy: RemoteSigned;
    

    then call powershell script in the following manner...

    (no need to pass full "powershell.exe" file path)

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

    then in the script, you can always read the 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");
    

提交回复
热议问题