-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
.build.ps1
153 lines (134 loc) · 3.78 KB
/
.build.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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<#
.Synopsis
Build script, https://github.com/nightroman/Invoke-Build
#>
param(
$Configuration = (property Configuration Release),
$FarHome = (property FarHome C:\Bin\Far\x64)
)
Set-StrictMode -Version 3
$ModuleName = 'RightWords'
$ModuleRoot = "$FarHome\FarNet\Modules\$ModuleName"
$Description = 'Spell-checker. FarNet module for Far Manager.'
task build meta, {
exec { dotnet build -c $Configuration /p:FarHome=$FarHome }
}
task publish {
exec { dotnet publish "$ModuleName.csproj" -c $Configuration -o $ModuleRoot --no-build }
},
help,
resgen
task help @{
Inputs = 'README.md'
Outputs = "$ModuleRoot\RightWords.hlf"
Jobs = {
exec { pandoc.exe README.md --output=z.htm --from=gfm }
exec { HtmlToFarHelp from=z.htm to=$ModuleRoot\RightWords.hlf }
remove z.htm
}
}
# https://github.com/nightroman/PowerShelf/blob/main/Invoke-Environment.ps1
task resgen @{
Inputs = 'RightWords.restext', 'RightWords.ru.restext'
Outputs = "$ModuleRoot\RightWords.resources", "$ModuleRoot\RightWords.ru.resources"
Partial = $true
Jobs = {
begin {
$VsDevCmd = @(Get-Item "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\VsDevCmd.bat")
Invoke-Environment.ps1 -File ($VsDevCmd[0])
}
process {
exec {resgen.exe $_ $2}
}
}
}
task clean {
remove z, bin, obj, README.htm, *.nupkg
}
task version {
($script:Version = switch -regex -file History.txt {'^= (\d+\.\d+\.\d+) =$' {$matches[1]; break}})
assert $script:Version
}
task meta -Inputs .build.ps1, History.txt -Outputs Directory.Build.props -Jobs version, {
Set-Content Directory.Build.props @"
<Project>
<PropertyGroup>
<Description>$Description</Description>
<Company>https://github.com/nightroman/FarNet</Company>
<Copyright>Copyright (c) Roman Kuzmin</Copyright>
<Product>FarNet.$ModuleName</Product>
<Version>$Version</Version>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
</Project>
"@
}
task markdown {
assert (Test-Path $env:MarkdownCss)
exec { pandoc.exe @(
'README.md'
'--output=README.htm'
'--from=gfm'
'--embed-resources'
'--standalone'
"--css=$env:MarkdownCss"
'--standalone', '--metadata=pagetitle=RightWords'
)}
}
task package markdown, version, {
remove z
$toModule = mkdir "z\tools\FarHome\FarNet\Modules\$ModuleName"
# module
exec { robocopy $ModuleRoot $toModule /s /xf *.pdb } (0..2)
equals 7 (Get-ChildItem $toModule -Recurse -File).Count
# meta
Copy-Item -Destination z @(
'README.md'
'..\Zoo\FarNetLogo.png'
)
# module
Copy-Item -Destination $toModule @(
"README.htm"
"History.txt"
"..\LICENSE"
"RightWords.macro.lua"
)
$result = Get-ChildItem $toModule -Recurse -File -Name | Out-String
$sample = @'
History.txt
LICENSE
README.htm
RightWords.deps.json
RightWords.dll
RightWords.hlf
RightWords.macro.lua
RightWords.resources
RightWords.ru.resources
RightWords.runtimeconfig.json
WeCantSpell.Hunspell.dll
'@
Assert-SameFile.ps1 -Text $sample $result $env:MERGE
}
task nuget package, version, {
equals $Script:Version (Get-Item "$ModuleRoot\$ModuleName.dll").VersionInfo.ProductVersion
Set-Content z\Package.nuspec @"
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>FarNet.RightWords</id>
<version>$script:Version</version>
<authors>Roman Kuzmin</authors>
<owners>Roman Kuzmin</owners>
<projectUrl>https://github.com/nightroman/FarNet</projectUrl>
<icon>FarNetLogo.png</icon>
<readme>README.md</readme>
<license type="expression">BSD-3-Clause</license>
<description>$Description</description>
<releaseNotes>https://github.com/nightroman/FarNet/blob/main/RightWords/History.txt</releaseNotes>
<tags>FarManager FarNet Module Hunspell</tags>
</metadata>
</package>
"@
exec { NuGet pack z\Package.nuspec }
}
task . build, clean