2

I've been trying to install the Rosyln source code from Github and following the build setup instructions.

The first instruction is to run Restore.cmd - which produces the following error message:

File C:\Code\roslyn-master\build\scripts\build.ps1 cannot be loaded. 
The file C:\Code\roslyn-master\build\scripts\build.ps1 is not digitally signed. 
You cannot run this script on the current system. For more information about 
running scripts and setting execution policy, see about_Execution_Policies 
at
http://go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo          : SecurityError: (:) [], 
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess

I have used Set-ExecutionPolicy to disable the checking:

PS C:\Code\roslyn-master> Get-ExecutionPolicy -List

Scope           ExecutionPolicy
-----           ---------------
MachinePolicy   Undefined
UserPolicy      Undefined
Process         Undefined
CurrentUser     Undefined
LocalMachine    Undefined

However, I am still receiving the same error. I'm running Visual Studio 2017 Community on a Windows 10 Pro machine.

Thanks in advance

Jim

Spodgy
  • 302
  • 5
  • 13
  • 1
    run `Set-ExecutionPolicy Unrestricted` from an admin powershell and try again? – colsw Aug 20 '17 at 15:06
  • Hi - yes I tried that initially - both for Unrestricted and Undefined (using an administrator command prompt running Powershell). Same results. It was then that I modified all the scopes - I've tried both Unrestricted and Undefined. – Spodgy Aug 21 '17 at 08:48
  • Have you tried?: Set-ExecutionPolicy RemoteSigned Process – Krisz Aug 21 '17 at 09:34
  • Same error unfortunately. – Spodgy Aug 21 '17 at 22:00

1 Answers1

1

The Restore.Cmd file contained the following command:

powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0\build\scripts\build.ps1" -restore %*

It didn't matter what I set the Powershell policy to - the file was going to override it. When I removed the execution policy clause, the file ran fine.

Spodgy
  • 302
  • 5
  • 13
  • Did you ever figure out why this was happening? I downloaded and got Roslyn up and running a month ago without experiencing this. Then today I downloaded it again, this time as a .zip download, not as a GitHub repository, and I ran into this problem. Can it be that "RemoteSigned" works if it sees that the script comes from a repository, and doesn't work for an "unconnected" download? – RenniePet Feb 21 '18 at 07:59
  • @RenniePet in my case it was the cmd files. I assumed initially the issue was with the setup of the powershell environment. In the cmd files however, like in the restore above, they're setting the policy in the command. When I removed the execution policy parameter they ran fine. I never found out why they were setup like that - I assume the ps1 files should have been signed but weren't. – Spodgy Feb 21 '18 at 08:44