-
Notifications
You must be signed in to change notification settings - Fork 0
/
msbuild.ps1
92 lines (76 loc) · 2.55 KB
/
msbuild.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#
# Wrapper script for MSBuild
#
param(
[string]$SolutionDir = "vs2019",
[string]$ConfigurationBase = "Windows 10",
[Parameter(Mandatory = $true)]
[string]$Arch,
[Parameter(Mandatory = $true)]
[string]$Type
)
Function Run-MSBuild {
param(
[string]$SolutionPath,
[string]$Name,
[string]$Configuration,
[string]$Platform,
[string]$Target = "Build",
[string]$Inputs = ""
)
$c = "msbuild.exe"
$c += " /m:4"
$c += [string]::Format(" /p:Configuration=""{0}""", $Configuration)
$c += [string]::Format(" /p:Platform=""{0}""", $Platform)
$c += [string]::Format(" /t:""{0}"" ", $Target)
if ($Inputs) {
$c += [string]::Format(" /p:Inputs=""{0}"" ", $Inputs)
}
$c += Join-Path -Path $SolutionPath -ChildPath $Name
Invoke-Expression $c
}
Function Run-MSBuildSDV {
param(
[string]$SolutionPath,
[string]$Name,
[string]$Configuration,
[string]$Platform
)
$basepath = Get-Location
$versionpath = Join-Path -Path $SolutionPath -ChildPath "version"
$projpath = Join-Path -Path $SolutionPath -ChildPath $Name
Set-Location $projpath
$project = [string]::Format("{0}.vcxproj", $Name)
Run-MSBuild $versionpath "version.vcxproj" $Configuration $Platform "Build"
Run-MSBuild $projpath $project $Configuration $Platform "Build"
Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/clean"
Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/check:default.sdv /debug"
Run-MSBuild $projpath $project $Configuration $Platform "dvl"
$refine = Join-Path -Path $projpath -ChildPath "refine.sdv"
if (Test-Path -Path $refine -PathType Leaf) {
Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/refine"
}
Copy-Item "*DVL*" -Destination $SolutionPath
Set-Location $basepath
}
#
# Script Body
#
$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; }
$platform = @{ "x86" = "Win32"; "x64" = "x64" }
$solutionpath = Resolve-Path $SolutionDir
Set-ExecutionPolicy -Scope CurrentUser -Force Bypass
if ($Type -eq "free") {
Run-MSBuild $solutionpath "xenvkbd.sln" $configuration["free"] $platform[$Arch]
}
elseif ($Type -eq "checked") {
Run-MSBuild $solutionpath "xenvkbd.sln" $configuration["checked"] $platform[$Arch]
}
elseif ($Type -eq "sdv") {
$archivepath = "xenvkbd"
if (-Not (Test-Path -Path $archivepath)) {
New-Item -Name $archivepath -ItemType Directory | Out-Null
}
Run-MSBuildSDV $solutionpath "xenvkbd" $configuration["sdv"] $platform[$Arch]
Copy-Item -Path (Join-Path -Path $SolutionPath -ChildPath "*DVL*") -Destination $archivepath
}