Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/Build.ps1 @ 16654

Last change on this file since 16654 was 16372, checked in by chaider, 6 years ago

#2971

  • Added references to projects
  • Added build events
File size: 3.6 KB
Line 
1# find ms build
2$programFilesX86Dir = ($Env:ProgramFiles, ${Env:ProgramFiles(x86)})[[bool]${Env:ProgramFiles(x86)}]
3$locations = @(
4  [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "Enterprise", "MSBuild", "15.0", "Bin", "amd64")
5  [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "Enterprise", "MSBuild", "15.0", "Bin")
6  [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "Community", "MSBuild", "15.0", "Bin", "amd64")
7  [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "Community", "MSBuild", "15.0", "Bin")
8  [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "BuildTools", "MSBuild", "15.0", "Bin", "amd64"),
9  [System.IO.Path]::Combine($programFilesX86Dir, "Microsoft Visual Studio", "2017", "BuildTools", "MSBuild", "15.0", "Bin")
10)
11
12$msBuildPath = $undefined
13Foreach ($loc in $locations) {
14  $loc = [System.IO.Path]::Combine($loc, "MSBuild.exe")
15  If ([System.IO.File]::Exists($loc)) {
16    $msBuildPath = $loc
17    Break;
18  }
19}
20
21if ($msBuildPath -eq $undefined) {
22  "Could not locate MSBuild, ABORTING ..."
23} else {
24  $curPath = $MyInvocation.MyCommand.Path
25  $curDir = Split-Path $curPath
26
27  $slnFiles = Get-ChildItem $curDir -Filter *.sln
28
29  "Found the following solutions:"
30
31  ""
32
33  $slnFiles | % { $i = 0 } { ("  {0}. `"{1}`"" -f ($i + 1), $_.Name); $i++ }
34
35  ""
36
37  $success = $false
38
39  # query solution to build
40  $slnIndex = -1
41  $slnIndices = @()
42  Do {
43      $input = Read-Host "Which solution(s) to build? {1..$($slnFiles.Count)}"
44      $inputParts = $input -Split " "
45
46      Foreach ($part in $inputParts) {
47        If ($part -eq "") { Continue }
48
49        $success = [int]::TryParse($part, [ref]$slnIndex) -and ($slnIndex -gt 0) -and ($slnIndex -le $slnFiles.Count)
50
51        If ($success) {
52          $slnIndices += $slnIndex - 1
53        } Else {
54          $slnIndices = @()
55          Break
56        }
57      }
58  } While (-Not $success)
59
60  $slnIndices = $slnIndices | Select-Object -Unique
61
62  # query configuration to build
63  $config = "Release"
64  $input = Read-Host "Which configuration to build? [$($config)]"
65  $config = ($config, $input)[[bool]$input]
66
67  # query platform to build
68  $platform = "Any CPU"
69  $input = Read-Host "Which platform to build? [$($platform)]"
70  $platform = ($platform, $input)[[bool]$input]
71
72  # query clean desire
73  $clean = $false
74  Do {
75      $input = Read-Host "Would you like to clean before building? [y/N]"
76      $input = ([string]("n", $input)[[bool]$input]).ToLowerInvariant()
77      $success = $input -eq "n" -or ($clean = $input -eq "y")
78  } While (-Not $success)
79
80  ""
81
82  if ($clean) {
83    Foreach ($slnIndex in $slnIndices) {
84      $solution = $slnFiles[$slnIndex]
85      "Cleaning `"$($solution.Name)`" ..."
86      $args = @(
87        $solution.FullName,
88        "/t:Clean",
89        "/p:Configuration=`"$config`",Platform=`"$platform`"",
90        "/m", "/nologo", "/verbosity:q", "/clp:ErrorsOnly"
91      )
92      & $msBuildPath $args
93      "===== CLEAN FINISHED ====="
94    }
95  }
96
97  Foreach ($slnIndex in $slnIndices) {
98    $solution = $slnFiles[$slnIndex]
99    "Building `"$($solution.Name)`" ($config|$platform) ..."
100    $args = @(
101      $solution.FullName,
102      "/t:Build",
103      "/p:Configuration=`"$config`",Platform=`"$platform`"",
104      "/m", "/nologo", "/verbosity:q", "/clp:ErrorsOnly"
105    )
106    & $msBuildPath $args
107    "===== BUILD FINISHED ====="
108  }
109}
110
111""
112
113Write-Host -NoNewline "Press any key to continue ... "
114[void][System.Console]::ReadKey($true)
Note: See TracBrowser for help on using the repository browser.