terminal/tools/bx.ps1
Mike Griese b495ad255f
Create bx.cmd (#2168)
* Try createing a script to only build the current working directory

  Inspired by #2078.

  I wanted to use this for WindowsTerminal, but I can't generate the
  resources.pri from just building WindowsTerminal. Maybe @dhowett-msft has
  some ideas.

* Cleanup for PR

* fix some bugs with building outside a project directory.

* PR nits
2019-08-05 20:18:40 -05:00

29 lines
1.1 KiB
PowerShell

# This is a helper script to figure out which target corresponds to the project
# in this directory. Parses the solution's .metaproj file looking for the
# project file in this directory, to be able to get the project's name.
$projects = Get-Childitem -Path .\ -Filter *.vcxproj -File
if ($projects.length -eq 0)
{
exit -1
}
$projectPath = $projects.FullName
$msBuildCondition = "'%(ProjectReference.Identity)' == '$projectPath.metaproj'"
# Parse the solution's metaproj file.
[xml]$Metaproj = Get-Content "$env:OPENCON\OpenConsole.sln.metaproj"
$targets = $Metaproj.Project.Target
# Filter to project targets that match out metaproj file.
# For Conhost\Server, this will match:
# [Conhost\Server, Conhost\Server:Clean, Conhost\Server:Rebuild, Conhost\Server:Publish]
$matchingTargets = $targets | Where-Object { $_.MSBuild.Condition -eq $msBuildCondition }
# Further filter to the targets that dont have a suffix (like ":Clean")
$matchingTargets = $matchingTargets | Where-Object { $hasProperty = $_.MsBuild.PSobject.Properties.name -match "Targets" ; return -Not $hasProperty }
Write-Host $matchingTargets.Name
exit 0