I am trying to work on a Windows laptop and setup a post_build.ps1 after the regular build of Visual Studio in VB.NET
When I run the script on powershell command, it doesn't have any error. But when I do it through Build in Visual Studio, I have this:
powershell ./_POST_BUILD.ps1 exited with code 1
If I enable the diagnostic output, I can see through the output this:
1> AuthorizationManager check failed. (TaskId:39)
1> + CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException (TaskId:39)
1> + FullyQualifiedErrorId : UnauthorizedAccess (TaskId:39)
What I tried:
- Set the policies to unrestricted with
Set-ExecutionPolicy Unrestricted -scope LocalMachineandSet-ExecutionPolicy Unrestricted -scope CurrentUser - Change the post build event in Visual Studio to
Powershell.exe -ExecutionPolicy Unrestricted -file "$(SolutionDir)bin\debug\_POST_BUILD.ps1" - Unblock file with right click -> properties -> unblock
- Run Visual Studio as administrator always