NuGet execution policy errors when installing MvcScaffolding package - asp.net

I'm using Visual Web Developer Express 2010, Windows XP, and using ASP.NET MVC4 RC in a project. I have NuGet v2.0.30619.9119 installed.
I'm now trying to install the MvcScaffolding package via NuGet Package Manager Console. I get the following errors:
PM> Install-Package MvcScaffolding
Attempting to resolve dependency 'T4Scaffolding'.
Attempting to resolve dependency 'EntityFramework (≥ 4.1.10311.0)'.
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=224682. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'EntityFramework 4.1.10715.0'.
Successfully installed 'T4Scaffolding 1.0.6'.
File Y:\asp\packages\T4Scaffolding.1.0.6\tools\init.ps1 cannot be loaded. The file Y:\asp\packages\T4Scaffolding.1.0.6\tools\init.ps
1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details..
At line:1 char:2
+ & <<<< 'Y:\asp\packages\T4Scaffolding.1.0.6\tools\init.ps1' $__rootPath $__toolsPath $__package $__project
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
Successfully installed 'MvcScaffolding 1.0.7'.
File Y:\asp\packages\MvcScaffolding.1.0.7\tools\init.ps1 cannot be loaded. The file Y:\asp\packages\MvcScaffolding.1.0.7\tools\init.
ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details..
At line:1 char:2
+ & <<<< 'Y:\asp\packages\MvcScaffolding.1.0.7\tools\init.ps1' $__rootPath $__toolsPath $__package $__project
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
Successfully added 'EntityFramework 4.1.10715.0' to MyProject.Web.
Successfully added 'T4Scaffolding 1.0.6' to MyProject.Web.
File Y:\asp\packages\T4Scaffolding.1.0.6\tools\install.ps1 cannot be loaded. The file Y:\asp\packages\T4Scaffolding.1.0.6\tools\inst
all.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details..
At line:1 char:2
+ & <<<< 'Y:\asp\packages\T4Scaffolding.1.0.6\tools\install.ps1' $__rootPath $__toolsPath $__package $__project
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
'InstallationDummyFile.txt' already exists. Skipping...
Successfully added 'MvcScaffolding 1.0.7' to MyProject.Web.
File Y:\asp\packages\MvcScaffolding.1.0.7\tools\install.ps1 cannot be loaded. The file Y:\asp\packages\MvcScaffolding.1.0.7\tools\in
stall.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details..
At line:1 char:2
+ & <<<< 'Y:\asp\packages\MvcScaffolding.1.0.7\tools\install.ps1' $__rootPath $__toolsPath $__package $__project
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
Because the init scripts aren't being executed after the install, the MvcScaffolding package is not installed correctly and the scaffold command is not recognised.
I don't know what to do about these code signing issues. Here are the current security settings:
PM> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process RemoteSigned
CurrentUser Undefined
LocalMachine Unrestricted
Can I change the Process scope to be Unrestricted? If so, how? Running Set-ExecutionPolicy in the NuGet console does not work:
PM> Set-ExecutionPolicy Unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):Y
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will
retain its current effective execution policy of "RemoteSigned". Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information, please see "Get-Help Set-ExecutionPol
icy."
At line:1 char:20
+ Set-ExecutionPolicy <<<< Unrestricted
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException
+ FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
I've also tried doing all of this as an Administrator and that didn't help either.
Any advice or ideas would be much appreciated.
UPDATE
I can set the process execution policy in NuGet like this:
Set-ExecutionPolicy Unrestricted -Scope Process
But when I restart Visual Web Developer, the setting is forgotten and I still get an error as it keeps trying to execute the init.psl files
How can I change the execution policy permanently?

OK, I have MvcScaffolding installed correctly now.
I had to first bypass all security in NuGet:
Set-ExecutionPolicy Bypass -Scope Process
But when I restart Visual Web Developer I still get those same PowerShell errors todo with the NuGet running init.pls on startup.
I've worked out that it's because I was storing my project on a network drive. Apparently PowerShell won't execute scripts from the network drive by default.
I tried using CasPol to change the security settings, but couldn't get it to work. I gave up when I saw other people couldn't get VS to work with mapped drives as well:
CAS not working for VS2010 mapped drive
Anyway, I just have my project local now, and MvcScaffolding is installed and working.

You can set the policy for user scope and using a more secure policy like this:
Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope CurrentUser
Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
Prompts you before running scripts from publishers that you have not yet classified as trusted or untrusted.
For exemple, installing a EntityFramework ask permission to run the script:
Executing script file 'c:\users\user\documents\visual studio 2015\Projects\zzz\packages\EntityFramework.6.1.3\tools\install.ps1'
Do you want to run software from this untrusted publisher?
File C:\users\user\documents\visual studio 2015\Projects\zzz\packages\EntityFramework.6.1.3\tools\install.ps1 is published by CN=Microsoft Corporation, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D"):R

Related

firebase.ps1 cannot be loaded because running scripts is disabled on this system

firebase sends this error if I try firebase init. can anyone please help me with this. I am new. and I don't really know much.
firebase : File C:\Users\USER\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on
this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
firebase init
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Step 1 :
open Windows PowerShell (Run as administrator)
Step 2 :
Type in Get-ExecutionPolicy -List and hit Enter.
Step 3 :
Type in Set-ExecutionPolicy Unrestricted and hit Enter again.
Step 4 :
Type Y and hit Enter.
Step 5 :
Type Set-ExecutionPolicy Unrestricted -Force and hit Enter.

Error when deploying .NET Core webapp to Azure

I am a complete beginner on the .NET world trying to get my first dummy .NET Core webapp to run on Azure App Service.
The code can be found here:
https://github.com/jordi-chacon/bcn_pollution
My development machine runs Ubuntu, so I am using Visual Studio Code.
I currently have my .NET Core webapp running on localhost:5000 just fine and now I want it to run on Azure App Service.
I have successfully configured Continuous Deployment on my App Service to fetch the code from Github.
Then Azure tried to deploy my webapp but it failed with the following error:
Using the following command to generate deployment script: 'azure site deploymentscript -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --aspNet5 "D:\home\site\repository\project.json" --aspNet5Version "1.0.0-rc1-final" --aspNet5Runtime "CLR" --aspNet5Architecture "x86"'.
Project file path: .\project.json
Generating deployment script for ASP.NET 5 Application
Generated deployment script files
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET 5 Web Application deployment.
Downloading dnx-clr-win-x86.1.0.0-rc1-final from https://www.nuget.org/api/v2
Unable to download package: An exception occurred during a WebClient request.
At C:\Program Files
(x86)\SiteExtensions\Kudu\50.41223.1987\bin\scripts\dnvm.ps1:694 char:13
+ throw "Unable to download package: {0}" -f
$Global:downloadData.Erro ...
+
Failed exitCode=1, command=PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='"D:\local\UserProfile\.dnx\temp-set-envvars.cmd"';& 'C:\Program Files (x86)\SiteExtensions\Kudu\50.41223.1987\bin\scripts\dnvm.ps1' " install 1.0.0-rc1-final -arch x86 -r CLR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to downl...Client requ
An error has occurred during web site deployment.
est.:String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to download package: An exception occurred during a WebClient request.
Anyone knows what I am doing wrong?
Thanks!
I guess you are hitting not enough disk space issue.
https://github.com/projectkudu/kudu/issues/1682
I tried your code, and repro the deployment failure.
when navigate to https://{site name}.scm.azurewebsites.net, i see below message
Parser Error Message: There is not enough space on the disk.
by default free site has 1 GB of disk space, but seems like it is an known issue that asp.net 5 application kind of require a lots of dependency and easily go over the limit. And they (Asp.net 5 folks) are working on addressing the issue.
walk-around is to deploy to a Basic or Standard site

Error While uploading to windows Azure using powershell Script

I am uploading the application to windows Azure using the powershell Script
New-AzureDeployment -ServiceName $servicename -Label MySite
-Slot "Staging" -Package "C:\Users\ronak\Documents\Visual Studio 2012\Projects\samplewebrole\samplewebrole\bin\Release\app.publish\samplewebrole.cspkg"
-Configuration "C:\Users\ronak\Documents\Visual Studio 2012\Projects\samplewebrole\samplewebrole\bin\Release\app.publish\ServiceConfiguration.Cloud.cscfg"
When I run this I receive an error as follows
New-AzureDeployment : Unable to write data to the transport connection: An
existing connection was forcibly closed by the remote host.
At line:14 char:1
+ New-AzureDeployment -ServiceName $servicename -Label MySite -Slot "Staging" -Pac...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureDeployment], StorageException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.HostedServices.NewAzureDeploymentCommand
To resolve this i found some suggestion to increase the size the asp.net can upload. Is there any other reason this is happening?
Also I am able to create cloud service and storage but cant upload my package to it.
I moved my script to the virtual machine which is hosted on azure and this error is no more so i think this error was due to my firewall or due to the slow internet connection.the script is running as desired on the virtual machine and i am able to automate my deployment process.

Can't get AWS Elastic Beanstalk Command Line Tool to work on Windows 8. Get the following PowerShell error?

Add-Type : Cannot add type due to the following exception: Compiler executable
file csc.exe cannot be found.. Verify that version 3.5 of the Microsoft .NET
Framework is installed. On 64-bit versions of Windows, the WOW64 component is
also required.
At C:\Users\Albert\Documents\WindowsPowerShell\Modules\AWSDevTools\AWSDevTools.
ps1:315 char:1
+ Add-Type -Language CSharpVersion3 -TypeDefinition $awsSource
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], InvalidOperationEx
ception
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Power
Shell.Commands.AddTypeCommand
PATH set to %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\wamp\bin\php\php5.4.3;C:\Program Files\Java\jre7\bin;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files\AWS-ElasticBeanstalk-CLI-2.4.0\eb\windows;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v4.0.30319
I'm following this tutorial online
Thanks
You need to install .NET 3.5 on your Windows 8 machine as it isn't installed by default. Open up the Control Panel, select Programs then Program and Features. Select the "Turn Windows Features on or off" link on the left and select .NET Framework 3.5 and press OK.

Enabling Code First Entity Framework VS Web Express 2012

I am trying to enable Code First in my Visual Studio Web Express 2012. From what I have read so far I have to use the Package Manager Console and the command Enable-Migrations. When I do this I get the following error.
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///E:\Working\wingtoysdl\C#\packages\EntityFramework.5
.0.0\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:398 char:62
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $toolsPath EntityFramework.PowerShell.Utility.dll))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
You cannot call a method on a null-valued expression.
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:399 char:50
+ $dispatcher = $utilityAssembly.CreateInstance <<<< (
+ CategoryInfo : InvalidOperation: (CreateInstance:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///E:\Working\wingtoysdl\C#\packages\EntityF
ramework.5.0.0\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
)"
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:431 char:31
+ $domain.CreateInstanceFrom <<<< (
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
As you can see it is a very large error making it very hard to google and troubleshoot. Does anyone have any ideas on how I can fix this?
I've run into this issue twice now. Both times I've had to uninstall entity framework then re-install it for each project in the solution. One thing that took me a while to figure out the second time I did this is that I had to re-start Visual Studio (2012) after re-installing Entity Framework (or I continued to get the "Could not load file or assembly '[path]\packages\EntityFramework.5
.0.0\tools\EntityFramework.PowerShell.Utility.dll'" error).
To get to the Package Manager Console go to: Tools -> Library Package Manager -> Package Manager Console
In the Package Manager uninstall Entity Framework for each project (I selected each project from the Default Project dropdown at the top of the Package Manager Console):
Uninstall-Package EntityFramework -Force
Then install it for each project:
Install-Package EntityFramework
At this point attempting to run the Enable-Migrations command gave the error still, until I closed and restarted Visual Studio. Then it was successful, as was the Update-Database command (after setting AutomaticMigrationsEnabled to true in the Migrations.Configuration file).
Had the same issue on two different machines while using projects on a network drive. This answer fixed it for me.
This may be a late answer but this seems like it could be a permissions/access problem.
Make sure that your project is not being opened from a mapped drive or similar.
If you are on a corporate network and logged into a domain, it is very likely that your user profile does not actually sit on your local computer but rather on the server. This will cause the same problem.
Try copy the project to your local c: and try again.
My problem was caused by some projects in my solution not being updated to the same version as other projects. When I ensured all were on the same EF version, it began working.
So I had the same problem for a while, I was unpacking a working project and got the error as I tried to enable migrations. It was simply fixed by using 7-Zip instead of the default unzipper from windows 10
I was also encounter the same problem so I started to check the possible things could go wrong and I found 2 different versions of entity framework is get installed somehow.
To confirm I goto Tools> NuGet package manager solution > Manage NuGet packages > Consolidate.
Have a look below images.
In this picture you may clearly see the different version is installed
in this picture I am agree to update the Entity Framework from 6.2.0 to 6.4.4
I had the same issue and in my case it was network drive problem. When I copied my project in local drive it worked fine.

Resources