powershell - 如何将解析路径与另一个目录连接

标签 powershell concatenation config octopus-deploy

如何将Web配置资源目录路径与已解析的主目录路径连接在一起。在Octopus中,resolve-path为我提供了正确的目录路径,但无法将该路径与另一个目录连接。我正在使用以下代码,请指导。

$webConfigResources = (resolve-path .)
$webConfigResources +=  "\ResourcesConfiguration.config"
$doc = (gc $webConfigResources) -as [xml]
$doc.SelectSingleNode('//resourcesConfigSection/resources/@baseDirectory').'#text' =            
$doc.Save($webConfigResources)

最佳答案

Resolve-Path返回一个System.Management.Automation.PathInfo对象(不是字符串)。使用Join-Path:

$webConfigResources = Join-Path (Resolve-Path .) "\ResourcesConfiguration.config"

关于powershell - 如何将解析路径与另一个目录连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18532120/

相关文章:

arrays - 将Powershell中的对象重定向到其他功能

javascript - 在 JavaScript 中将对象字段与变量连接起来

ruby - 为什么我不能连接两个字符串并将它们分配给一个符号?

c++ - 简化涉及在 C++ 中连接整数的 std::string 构造

javascript - 我如何关闭这部分 CK 编辑器?

javascript - 无法启动 Node 应用程序配置文件

powershell - 在属性中使用哈希表键

powershell - PowerShell属性问题

powershell - 忽略Powershell中的Get-childItem目录

git - 在 git rebase 期间自动忽略日期