0
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
</Project>

К примеру нужно вытащить "bin\Release" из релизной конфигурации:

[xml]$proj = (Get-Content $projectFileName)

$nsmgr = New-Object System.Xml.XmlNamespaceManager $proj.NameTable

$nsmgr.AddNamespace('a','http://schemas.microsoft.com/developer/msbuild/2003')

$assemblyName = $proj.SelectSingleNode('//a:AssemblyName', $nsmgr)

$node = $proj.SelectNodes("//a:PropertyGroup[@Condition]", $nsmgr)

$outputPath = $node| ? Condition -Like '*Release*' | select OutputPath

Можно ли как нибудь вытащить эту строку, только с помощью SelectNodes, что-то типо такого:

SelectNodes("//a:PropertyGroup[@Condition -Like '*Release*']", $nsmgr)

1 ответ 1

1

Да, можно, XPath поддерживает функцию contains():

SelectNodes("//a:PropertyGroup[contains(@Condition, 'Release')]/a:OutputPath", $nsmgr)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.