Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/Build.ps1 @ 16223

Last change on this file since 16223 was 16223, checked in by jkarder, 5 years ago

#2951: updated build script

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