Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell Set-AzureDeployment忽略相对路径_Powershell_Azure - Fatal编程技术网

Powershell Set-AzureDeployment忽略相对路径

Powershell Set-AzureDeployment忽略相对路径,powershell,azure,Powershell,Azure,与其在当前目录中查找serviceconfigation.Test.cscfg文件,Set-AzureDeployment希望在当前用户的主目录中找到此文件,坦率地说,这非常令人讨厌 是否存在某种常见的Powershell模式来运行从主目录开始的所有cmdlet函数?为什么?您可以显式地传递完整路径: PS C:\Users\dimon\src\panama\Panama> Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "

与其在当前目录中查找
serviceconfigation.Test.cscfg
文件,
Set-AzureDeployment
希望在当前用户的主目录中找到此文件,坦率地说,这非常令人讨厌


是否存在某种常见的Powershell模式来运行从主目录开始的所有cmdlet函数?为什么?

您可以显式地传递完整路径:

PS C:\Users\dimon\src\panama\Panama> Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "Production" -Configuration .\ServiceConfiguration.Test.cscfg -Verbose
Set-AzureDeployment : Could not find a part of the path 'C:\Users\dimon\ServiceConfiguration.Test.cscfg'.
At line:1 char:1
+ Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "Production" -Configur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-AzureDeployment], DirectoryNotFoundException
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.SetAzureDeploymentCommand
回答您的问题:不,PowerShell对主目录没有任何特殊功能。但是,如果执行
cd
,则暴露于非PowerShell命令的当前目录的值(
[Environment]::CurrentDirectory
)不会更改,这通常会引起意外。如果
Set AzureDeployment
将其参数传递给非PowerShell命令,则可以解释该行为

要以常规方式解决此问题,只需在发出进一步命令之前将当前目录更改为PowerShell的位置:

Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "Production" `
  -Configuration $(rvpa .\ServiceConfiguration.Test.cscfg) -Verbose

显然,只有当当前位置在文件系统中,而不是PowerShell支持的任何其他外来位置时,这才有效。

相对路径会被视为管道值吗?如果是这样,则
-Configuration
开关不接受MSDN中的管道值。我想知道
-Configuration
如何处理该字符串数据。它接受字符串,但试图以某种方式转换它<代码>解析路径可能是一种解决方法,但我很好奇如何为
-Configuration
定义参数及其数据验证。
[Environment]::CurrentDirectory = $(pwd)