<?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> 

For example, you need to pull out "bin \ Release" from the release configuration:

 [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 

Is it possible to pull out this line somehow, just using SelectNodes, something like this:

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

    1 answer 1

    Yes, you can, XPath supports the function contains() :

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