4

Visual Web Developer Express 2010、Windows XPを使用しており、プロジェクトでASP.NETMVC4RCを使用しています。NuGetv2.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ファイルを実行しようとし続けるため、エラーが発生します。

実行ポリシーを永続的に変更するにはどうすればよいですか?

4

2 に答える 2

13

OK、MvcScaffoldingが正しくインストールされました。

最初に、NuGetのすべてのセキュリティをバイパスする必要がありました。

Set-ExecutionPolicy Bypass -Scope Process

ただし、Visual Web Developerを再起動すると、起動時にNuGetを実行init.plsした場合と同じPowerShellエラーが発生します。

プロジェクトをネットワークドライブに保存していたためだとわかりました。どうやらPowerShellはデフォルトでネットワークドライブからスクリプトを実行しません。

CasPolを使用してセキュリティ設定を変更しようとしましたが、機能しませんでした。他の人がVSをマップされたドライブでも動作させることができないのを見たとき、私はあきらめました:

CASがVS2010マップドライブで機能しない

とにかく、私は今プロジェクトをローカルに持っており、MvcScaffoldingがインストールされて機能しています。

于 2012-07-04T00:28:51.850 に答える
1

ユーザースコープのポリシーを設定し、次のようなより安全なポリシーを使用できます。

Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope CurrentUser

ローカルコンピューターで作成するスクリプトを含め、すべてのスクリプトと構成ファイルが信頼できる発行元によって署名されている必要があります。まだ信頼できるまたは信頼できないとして分類されていない発行元からスクリプトを実行する前にプロンプ​​トを表示します。

たとえば、EntityFrameworkをインストールすると、スクリプトを実行する権限が要求されます。

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
于 2015-06-05T19:35:44.513 に答える