【问题标题】:File cannot be loaded because the execution of scripts is disabled on this system with pubxml无法加载文件,因为在此系统上使用 pubxml 禁用了脚本的执行
【发布时间】:2016-02-18 11:07:49
【问题描述】:

我有一个非常特殊的情况。我正在使用脚本来执行部署后操作。 我的 .pubml 中有以下 sn-p 代码

<Target Name="CopyServiceModules"  AfterTargets="MSDeployPublish">
<Exec Command="powershell.exe -file &quot;$(SolutionDir)PowerShellScripts\CopyModulesFiles.ps1&quot; -workspacePath &quot;$(ProjectDir)Modules&quot; -deployPath &quot;$(_MSDeployDirPath_FullPath)\Modules&quot;" />

如果我从 powershell 运行脚本,它可以工作,当它由 Visual Studio 执行时,我收到此错误

file cannot be loaded because the execution of scripts is disabled on this system with pubxml file

我刚刚跑了

 Set-ExecutionPolicy Unrestricted

在我的机器上,但它不起作用。 我还以管理员权限运行 Visual Studio 2015

有什么建议吗? 谢谢

【问题讨论】:

    标签: visual-studio powershell visual-studio-2015 webdeploy


    【解决方案1】:

    尝试将 -ExecutionPolicy 添加到您的 Exec 行:

    <Exec Command="powershell.exe -ExecutionPolicy Bypass -file &quot;$(SolutionDir)PowerShellScripts...
    

    【讨论】:

    • 谢谢!现在我有最后一个问题,但我打开另一个线程
    猜你喜欢
    • 2013-10-06
    • 2013-05-03
    • 2021-10-27
    • 2017-04-28
    • 2020-03-06
    • 2021-02-22
    • 2020-06-20
    • 2022-10-25
    • 2020-03-11
    相关资源
    最近更新 更多