代码之家  ›  专栏  ›  技术社区  ›  Tasos

未经授权访问Visual Studio的后期生成

  •  3
  • Tasos  · 技术社区  · 8 年前

    我正在尝试使用Windows笔记本电脑并设置 post_build.ps1

    当我在powershell命令上运行脚本时,它没有任何错误。但是,当我通过Visual Studio中的Build实现时,我有以下几点:

    powershell ./_POST_BUILD.ps1 exited with code 1

    1>  AuthorizationManager check failed. (TaskId:39)
    1>      + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException (TaskId:39)
    1>      + FullyQualifiedErrorId : UnauthorizedAccess (TaskId:39)
    

    我尝试的内容:

    1. 使用将策略设置为无限制 Set-ExecutionPolicy Unrestricted -scope LocalMachine Set-ExecutionPolicy Unrestricted -scope CurrentUser
    2. Powershell.exe -ExecutionPolicy Unrestricted -file "$(SolutionDir)bin\debug\_POST_BUILD.ps1"
    3. 用鼠标右键取消阻止文件->属性->取消阻止
    3 回复  |  直到 8 年前
        1
  •  1
  •   Tasos    8 年前

    我不想回答自己的问题,但我设法解决了。

    unblock-file --path ./_POST_BUILD.ps1

        2
  •  0
  •   user169771    8 年前

    确保脚本的测试运行在与Visual Studio相同的用户帐户(可能是)和UAC提升/未提升状态下运行(因为您尝试使用VS提升,这很可能是个问题)。

    本页( http://tgnp.me/2011/09/powershell-authorizationmanager-check-failed-resolution/ )建议确保WMI服务正在运行。

        3
  •  0
  •   Mehmet Ozden    6 年前

    在Visual Studio Powershell上复制,在关闭VS后运行。

    Set-ExecutionPolicy –ExecutionPolicy RemoteSigned