Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2965_CancelablePersistence/Build.ps1 @ 16710

Last change on this file since 16710 was 16433, checked in by pfleck, 6 years ago

#2965 Merged recent trunk changes.
Enabled the prepared hooks that allows to cancel the save file using the recently introduced cancelable progressbars (in FileManager).

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