gpt4 book ai didi

asp.net - 安装 MvcScaffolding 包时出现 NuGet 执行策略错误

转载 作者:行者123 更新时间:2023-12-01 07:42:28 25 4
gpt4 key购买 nike

我在一个项目中使用 Visual Web Developer Express 2010、Windows XP 和 ASP.NET MVC4 RC。我安装了 NuGet v2.0.30619.9119。

我现在正在尝试通过 NuGet 包管理器控制台安装 MvcScaffolding 包。我收到以下错误:

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

因为安装后没有执行init脚本,MvcScaffolding包安装不正确, scaffold命令无法识别。

我不知道如何处理这些代码签名问题。以下是当前的安全设置:
PM> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process RemoteSigned
CurrentUser Undefined
LocalMachine Unrestricted

我可以将流程范围更改为不受限制吗?如果是这样,如何?在 NuGet 控制台中运行 Set-ExecutionPolicy 不起作用:
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

我也尝试以管理员身份执行所有这些操作,但也无济于事。

任何建议或想法将不胜感激。

更新

我可以像这样在 NuGet 中设置流程执行策略:
Set-ExecutionPolicy Unrestricted -Scope Process

但是当我重新启动 Visual Web Developer 时,设置被忘记了,我仍然收到错误,因为它一直在尝试执行 init.psl 文件

如何永久更改执行策略?

最佳答案

好的,我现在已经正确安装了 MvcScaffolding。

我必须首先绕过 NuGet 中的所有安全性:

Set-ExecutionPolicy Bypass -Scope Process

但是,当我重新启动 Visual Web Developer 时,我仍然遇到与 NuGet 在启动时运行 init.pls 时相同的 PowerShell 错误。

我已经确定这是因为我将我的项目存储在网络驱动器上。显然 PowerShell 默认不会从网络驱动器执行脚本。

我尝试使用 CasPol 更改安全设置,但无法使其正常工作。当我看到其他人也无法让 VS 使用映射驱动器时,我放弃了:

CAS not working for VS2010 mapped drive

无论如何,我现在只有我的项目在本地,并且 MvcScaffolding 已安装并正常工作。

关于asp.net - 安装 MvcScaffolding 包时出现 NuGet 执行策略错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11306339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com