FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
RevitDevTool/scripts/build-host.ps1 at develop · trgiangv/RevitDevTool · GitHub
trgiangv
RevitDevTool
Repository navigation
Code
Issues
Pull requests
1
(1)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
RevitDevTool
/
scripts
/
build-host.ps1
Copy path
More file actions
More file actions
Latest commit
History
History
History
120 lines (106 loc) · 3.78 KB
Breadcrumbs
RevitDevTool
/
scripts
/
build-host.ps1
Copy path
File metadata and controls
120 lines (106 loc) · 3.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<#
.
SYNOPSIS
Stop the selected host years, then build those hosts.
.
DESCRIPTION
For each year, stops only the Revit or AutoCAD process whose install folder
matches that product and year. Other running years stay up.
One host builds that host project. Both hosts build RevitDevTool.slnx once
for the year, which deploys both add-ins.
.
PARAMETER
HostApp
Revit, AutoCAD, or both. Default is both.
.
PARAMETER
Year
One or more Autodesk years, or all. Default is all (2022-2027).
.
PARAMETER
Mode
Debug or Release. Default is Release.
.
EXAMPLE
scripts/build-host.ps1
scripts/build-host.ps1 -HostApp Revit -Year 2025 -Mode Debug
scripts/build-host.ps1 -HostApp Revit,AutoCAD -Year 2025,2026
#>
[
CmdletBinding
(
SupportsShouldProcess
)]
param
(
[
string
[]]
$HostApp
=
@
(
"
Revit
"
,
"
AutoCAD
"
)
,
[
string
[]]
$Year
=
@
(
"
all
"
)
,
[
ValidateSet
(
"
Debug
"
,
"
Release
"
)]
[
string
]
$Mode
=
"
Release
"
)
$ErrorActionPreference
=
"
Stop
"
.
(
Join-Path
$PSScriptRoot
'
_lib.ps1
'
)
Assert-RepoRoot
$allowedHosts
=
@
(
"
Revit
"
,
"
AutoCAD
"
)
$allowedYears
=
@
(
"
2022
"
,
"
2023
"
,
"
2024
"
,
"
2025
"
,
"
2026
"
,
"
2027
"
)
$hosts
=
@
(
$HostApp
|
ForEach-Object
{
$_
-split
'
,
'
}
|
ForEach-Object
{
$_
.Trim
() }
|
Where-Object
{
$_
}
|
Select-Object
-
Unique)
$years
=
@
(
$Year
|
ForEach-Object
{
$_
-split
'
,
'
}
|
ForEach-Object
{
$_
.Trim
() }
|
Where-Object
{
$_
}
|
Select-Object
-
Unique)
foreach
(
$app
in
$hosts
) {
if
(
$allowedHosts
-notcontains
$app
) {
throw
"
HostApp must be Revit or AutoCAD. Got '
$app
'.
"
}
}
if
(
$years
.Count
-eq
0
-or
@
(
$years
|
Where-Object
{
$_
-eq
"
all
"
}).Count
-gt
0
) {
$years
=
$allowedYears
}
else
{
foreach
(
$hostYear
in
$years
) {
if
(
$allowedYears
-notcontains
$hostYear
) {
throw
"
Year must be 2022-2027 or all. Got '
$hostYear
'.
"
}
}
}
function
Stop-HostYear
{
[
CmdletBinding
(
SupportsShouldProcess
)]
param
(
[
string
]
$App
,
[
string
]
$HostYear
)
$processName
=
if
(
$App
-eq
"
Revit
"
) {
"
Revit
"
}
else
{
"
acad
"
}
$productFolder
=
"
$App
$HostYear
"
$matching
=
@
()
$untouched
=
@
()
foreach
(
$process
in
@
(
Get-Process
-
Name
$processName
-
ErrorAction SilentlyContinue)) {
$folder
=
try
{
Split-Path
-
Leaf (
Split-Path
-
Parent
$process
.Path
) }
catch
{
$null
}
if
([
string
]::Equals(
$folder
,
$productFolder
,
[
StringComparison
]::OrdinalIgnoreCase)) {
$matching
+=
$process
}
else
{
$untouched
+=
$process
}
}
if
(
$untouched
.Count
-gt
0
) {
Write-Output
"
Leaving other
$App
versions untouched (PID:
$
(
$untouched
.Id
-join
'
,
'
)
).
"
}
if
(
$matching
.Count
-eq
0
) {
Write-Output
"
$App
$HostYear
is not running.
"
return
}
foreach
(
$process
in
$matching
) {
if
(
$PSCmdlet
.ShouldProcess
(
"
$
(
$process
.Path
)
(PID
$
(
$process
.Id
)
)
"
,
"
Stop
$App
$HostYear
"
)) {
Stop-Process
-
Id
$process
.Id
-
Force
$process
.WaitForExit
(
10000
)
|
Out-Null
Write-Output
"
Stopped
$App
$HostYear
(PID
$
(
$process
.Id
)
).
"
}
}
}
function
Build-HostYear
{
[
CmdletBinding
(
SupportsShouldProcess
)]
param
([
string
]
$HostYear
)
$configuration
=
"
$Mode
.Autodesk.
$HostYear
"
if
(
$hosts
.Count
-ge
2
) {
$project
=
Join-RepoPath
'
RevitDevTool.slnx
'
}
elseif
(
$hosts
[
0
]
-eq
"
Revit
"
) {
$project
=
Join-RepoPath
'
source/RevitDevTool/RevitDevTool.csproj
'
}
else
{
$project
=
Join-RepoPath
'
source/AcadDevTool/ACadDevTool.csproj
'
}
if
(
$PSCmdlet
.ShouldProcess
(
$project
,
"
dotnet build -c
$configuration
"
)) {
dotnet build
$project
-
c
$configuration
if
(
$LASTEXITCODE
-ne
0
) {
exit
$LASTEXITCODE
}
}
}
foreach
(
$hostYear
in
$years
) {
foreach
(
$app
in
$hosts
) {
Stop-HostYear
-
App
$app
-
HostYear
$hostYear
}
Build-HostYear
-
HostYear
$hostYear
}
Back
|
FazBrowse Home
|
New Git URL