Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/Build.ps1 @ 18238

Last change on this file since 18238 was 18226, checked in by jkarder, 3 years ago

#3017: updated build and test scripts to support VS 2022

File size: 10.1 KB
Line 
1# find ms build
2$programFilesDirs = @($Env:ProgramFiles, ${Env:ProgramFiles(x86)})
3$years = @("2022", "2019", "2017")
4$editions = @("Enterprise", "Professional", "Community", "BuildTools")
5$versions = @("Current", "15.0")
6
7$msBuildPath = $undefined
8:search Foreach ($dir in $programFilesDirs) {
9  $vsDir = [System.IO.Path]::Combine($dir, "Microsoft Visual Studio")
10  Foreach ($year in $years) {
11    $loc = [System.IO.Path]::Combine($vsDir, $year)
12    Foreach ($edition in $editions) {
13      $edLoc = [System.IO.Path]::Combine($loc, $edition, "MSBuild")
14      Foreach ($version in $versions) {
15        $binLoc = [System.IO.Path]::Combine($edLoc, $version, "Bin")
16        $loc64 = [System.IO.Path]::Combine($binLoc, "amd64", "MSBuild.exe")
17        $loc32 = [System.IO.Path]::Combine($binLoc, "MSBuild.exe")
18
19        If ([System.IO.File]::Exists($loc64)) {
20          $msBuildPath = $loc64
21          Break search;
22        }
23        If ([System.IO.File]::Exists($loc32)) {
24          $msBuildPath = $loc32
25          Break search;
26        }
27      }
28    }
29  }
30}
31
32Try {
33  If ($msBuildPath -eq $undefined) {
34    "Could not locate MSBuild, ABORTING ..."
35    Return
36  }
37
38  "MSBuild located at `"{0}`"." -f $msBuildPath
39
40  $curPath = $MyInvocation.MyCommand.Path
41  $curDir = Split-Path $curPath
42
43  $slnFiles = Get-ChildItem $curDir -Filter *.sln
44
45  If ($slnFiles.Count -le 0) {
46    "No solutions found, ABORTING ..."
47    Return
48  }
49
50  $slnIndices = @()
51
52  If ($slnFiles.Count -eq 1) {
53    "Selecting the only solution found: `"{0}`"" -f $slnFiles[0].Name
54    $slnIndices += 0
55  } Else {
56    "Found the following solutions:"
57
58    ""
59
60    $slnFiles | % { $i = 0 } { ("  {0}. `"{1}`"" -f ($i + 1), $_.Name); $i++ }
61
62    ""
63
64    $success = $false
65
66    # query solution to build
67    $slnIndex = -1
68    Do {
69        $input = Read-Host "Which solution(s) to build? (e.g.: 1 2 3) { 1..$($slnFiles.Count) }"
70        $inputParts = $input -Split " "
71
72        Foreach ($part in $inputParts) {
73          If ($part -eq "") { Continue }
74
75          $success = [int]::TryParse($part, [ref]$slnIndex) -and ($slnIndex -gt 0) -and ($slnIndex -le $slnFiles.Count)
76
77          If ($success) {
78            $slnIndices += $slnIndex - 1
79          } Else {
80            $slnIndices = @()
81            Break
82          }
83        }
84    } While (-Not $success)
85
86    $slnIndices = $slnIndices | Select-Object -Unique
87  }
88
89
90  # query configuration to build
91  $config = "Release"
92  $input = Read-Host "Which configuration to build? [$($config)]"
93  $config = ($config, $input)[[bool]$input]
94
95  # query platform to build
96  $platform = "Any CPU"
97  $input = Read-Host "Which platform to build? [$($platform)]"
98  $platform = ($platform, $input)[[bool]$input]
99
100  # query clean desire
101  $clean = $false
102  Do {
103      $input = Read-Host "Would you like to clean before building? [y/N]"
104      $input = ([string]("n", $input)[[bool]$input]).ToLowerInvariant()
105      $success = $input -eq "n" -or ($clean = $input -eq "y")
106  } While (-Not $success)
107
108  ""
109
110  If ($clean) {
111    Foreach ($slnIndex in $slnIndices) {
112      $solution = $slnFiles[$slnIndex]
113      "Cleaning `"$($solution.Name)`" ..."
114      $args = @(
115        $solution.FullName,
116        "/t:Clean",
117        "/p:Configuration=`"$config`",Platform=`"$platform`"",
118        "/m", "/nologo", "/verbosity:q", "/clp:ErrorsOnly"
119      )
120      & $msBuildPath $args
121      "===== CLEAN FINISHED ====="
122    }
123  }
124
125  Foreach ($slnIndex in $slnIndices) {
126    $solution = $slnFiles[$slnIndex]
127    "Building `"$($solution.Name)`" ($config|$platform) ..."
128    $args = @(
129      $solution.FullName,
130      "/t:Restore,Build",
131      "/p:Configuration=`"$config`",Platform=`"$platform`"",
132      "/m", "/nologo", "/verbosity:q", "/clp:ErrorsOnly"
133    )
134    & $msBuildPath $args
135    "===== BUILD FINISHED ====="
136  }
137} Finally {
138  ""
139
140  Write-Host -NoNewline "Press any key to continue ... "
141
142  [void][System.Console]::ReadKey($true)
143}
144
145# SIG # Begin signature block
146# MIIRPwYJKoZIhvcNAQcCoIIRMDCCESwCAQExDzANBglghkgBZQMEAgEFADB5Bgor
147# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
148# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCLZ/JdonyPX9Cp
149# TUV5DfnTZ07ydZrQLEzhh6BA4aW6eKCCDo4wggbaMIIEwqADAgECAhNoAAE6ILAh
150# JeBjaP8pAAEAATogMA0GCSqGSIb3DQEBCwUAMD4xEjAQBgoJkiaJk/IsZAEZFgJh
151# dDEVMBMGCgmSJomT8ixkARkWBWZob29lMREwDwYDVQQDEwhGSE9PZUNBMTAeFw0x
152# OTExMDYwOTI1NTJaFw0yNDExMDQwOTI1NTJaMD4xFjAUBgNVBAsTDUZ1RSBIYWdl
153# bmJlcmcxJDAiBgNVBAMTG0ZIIE9PRSBTdHVkaWVuYmV0cmllYnMgR21iSDCCASIw
154# DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANCook/YMdRq1PdL6DPB2ktDaZ5U
155# 5+fP9EwD+fjS5CgpsSy8U54tFwKwAohaBl4SAsobOEDwTHFqn0g2SWrj/Kct+pAB
156# a+1lFOFV6YsV5rj+ldPDpQde8bXO+XWTN/6+9zd//Xrxem6Zk1ObeDOrsOUr9PLT
157# JIYAWN5Iwp2ziKmsgxBxJHx5FU7pTgB/RhZ2gqu+w5uPZEg8rtUQqwvaNREmIEGg
158# XStODc1yLzcEx1VyWA1DUmdB6e4LLIh/NwYiOHrObdazS9IsI1DOD1jcTScBL5je
159# CAZF+smlJGw6GJXztgRoU5d2IcpVwpzCOBbNfkuxwbJRrjGyp0kPFxWm5zECAwEA
160# AaOCAs8wggLLMD0GCSsGAQQB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WWFw/kX7hPwrjsfojZoMWT+17ogBB7LVLQG90DwzPVFtAmyPdIJ8/
177# tbu1nu+kRR6qyC3iPW8RZetjT5FAyxHSPNvyI1INXenHmShwkG1hjvjVOGiBECh3
178# bfrY95qbZNdBpYee9xqEGlOj/LkRokM+hTlj65MgkFHGwPkiR6AZhnC6tVg3j2wX
179# Y+0yaYiXc+iNWOLmQDVwxBmD5bEzToH7EoTsCNcxkatvNzwapdyyz8ycENqyVAGQ
180# DxcEf2xNKZQU6PV1xJC8ltfpL4fL2MVQQ35VazMKGm+FeY5Jw+z7tph7Yxseb7KP
181# wy4iKY9GAt7bEIJSSUNX0ni/MoWULsdU3EQDPedMS5v3I5C+7GfDJiThq+b2xSm3
182# UIImrG+saST3hmC0fM3iffoujzn1tFm2POnNtIwL1X165quLCRhs4YHm57CxRcei
183# LfETrOL3Qd08w1nJVnsEvppqe4NauzdO4jPbxsSFCse10xO/2TW1C/ugraXv1fSU
184# HlYpUtt+wGhFV75QspOgUgWGc3KBMYm1XwjTWRwBZUd3l7S3UP6IqHaRu3I7eBsF
185# OUArTCtXSK+szMW+1G1gIoT61ZyxemUjg9GuF7qIRwlt+Bax4Jy1aZ1TsmV0z1SS
186# nBxuiKeBO1MwggesMIIFlKADAgECAhMeAAAABpSzaQpcq/lwAAEAAAAGMA0GCSqG
187# SIb3DQEBCwUAMBcxFTATBgNVBAMTDEZIT09lUm9vdENBMTAeFw0xNTA1MDcxMjIy
188# MzFaFw0yNzA1MDcxMjMyMzFaMD4xEjAQBgoJkiaJk/IsZAEZFgJhdDEVMBMGCgmS
189# JomT8ixkARkWBWZob29lMREwDwYDVQQDEwhGSE9PZUNBMTCCAiIwDQYJKoZIhvcN
190# AQEBBQADggIPADCCAgoCggIBAMA7PbbPxLUYOLUThQt0UWtwpT5rT1ZIRinD/wXG
191# asjsvxTEsWDG6kf0tLyLlf64zNOhtXG5pbidu+rcmdnlut58h9So8QuZELdb8xbS
192# 9rM3oTC9wKGW57oRydxIo7WkQw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UwBd9qdP6MbWEtFTj0d0LCPOA5Pw7p2m1p3HEMI6mcX
225# 4Fi+KO6CIvlX+SKrZwIattLO3VQZqV68/W3fmyC2FYwfVUU/InwIDGx3hXR3i+zr
226# t41t11bnp8B4Bhq7PXKgUEHuX0gcNE0o62HstYOf/U5HkCM+Ag43gFrR/RDwMq6L
227# 7VxKws52ao8xggIHMIICAwIBATBVMD4xEjAQBgoJkiaJk/IsZAEZFgJhdDEVMBMG
228# CgmSJomT8ixkARkWBWZob29lMREwDwYDVQQDEwhGSE9PZUNBMQITaAABOiCwISXg
229# Y2j/KQABAAE6IDANBglghkgBZQMEAgEFAKCBhDAYBgorBgEEAYI3AgEMMQowCKAC
230# gAChAoAAMBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisGAQQBgjcCAQsx
231# DjAMBgorBgEEAYI3AgEVMC8GCSqGSIb3DQEJBDEiBCB8JQqTFBBqCVI0KaLbaLg0
232# flx9+g0aPjepZMuhphj42jANBgkqhkiG9w0BAQEFAASCAQAPafrPJVGSrB1pcCdm
233# 7V2X2/bYyfBFxOaHI2p79UIHt5Z+PfDWuC5+ikrODQ+6FmGErfy/RN2Z1uueNUt5
234# aMhCn86vLGehThRoEGL+YDJg+/WKplowdHGkNB65yXC4CXe9NZLs02EVlljIO0yh
235# g8ITIZI1l1+njG7G8TMCwyLf/AAHaZpNZMlKSO1P0PQi8D2ggo3G0EwogPyN4AvJ
236# X877LhU4jEzX8lEouMXhilz8UQBrxrdXXWIbOUCNnXeIDVIUqf4HnsGnWGlwcQQb
237# BPUTwKveuKWSUHkk2zhMFAhuRNfm6KLBZaKdcVWaXEu66SChg68m4xjlLwy5jC+E
238# K2XI
239# SIG # End signature block
Note: See TracBrowser for help on using the repository browser.