1
- param (
1
+ param (
2
2
[string ]$buildNumber = " 0" ,
3
3
[string ]$extensionVersion = " 2.0.$buildNumber " ,
4
4
[string ]$versionSuffix = " $buildNumber "
5
5
)
6
6
7
7
$currentDir = Split-Path - Parent $MyInvocation.MyCommand.Path
8
8
$buildOutput = Join-Path $currentDir " buildoutput"
9
- $publishTarget = " $buildOutput \publish"
10
- $siteExtensionPath = " $publishTarget \SiteExtensions"
11
- $privateSiteExtensionPath = " $siteExtensionPath \Functions"
12
9
13
10
function ZipContent ([string ] $sourceDirectory , [string ] $target )
14
11
{
@@ -22,26 +19,151 @@ function ZipContent([string] $sourceDirectory, [string] $target)
22
19
[IO.Compression.ZipFile ]::CreateFromDirectory($sourceDirectory , $target )
23
20
}
24
21
22
+ function CrossGen ([string ] $runtime , [bool ] $isSelfContained , [string ] $publishTarget , [string ] $privateSiteExtensionPath )
23
+ {
24
+ Write-Host " publishTarget: " $publishTarget
25
+ Write-Host " privateSiteExtensionPath: " $privateSiteExtensionPath
26
+
27
+ $selfContained = Join-Path $publishTarget " self-contained"
28
+ $regular = Join-Path $publishTarget " regular"
29
+ $crossGen = " $publishTarget \download\crossgen\crossgen.exe"
30
+
31
+ # DownloadNupkg "https://dotnet.myget.org/F/dotnet-core/api/v2/package/runtime.$runtime.microsoft.netcore.jit/2.1.0-preview2-26316-09" @("runtimes\$runtime\native\clrjit.dll") @("$publishTarget\download\clrjit")
32
+ # DownloadNupkg "https://dotnet.myget.org/F/dotnet-core/api/v2/package/runtime.$runtime.Microsoft.NETCore.Runtime.CoreCLR/2.1.0-preview2-26316-09" @("tools\crossgen.exe") @("$publishTarget\download\crossgen")
33
+
34
+ DownloadNupkg " https://www.nuget.org/api/v2/package/runtime.$runtime .Microsoft.NETCore.Jit/2.0.5" @ (" runtimes\$runtime \native\clrjit.dll" ) @ (" $publishTarget \download\clrjit" )
35
+ DownloadNupkg " https://www.nuget.org/api/v2/package/runtime.$runtime .Microsoft.NETCore.Runtime.CoreCLR/2.0.5" @ (" tools\crossgen.exe" ) @ (" $publishTarget \download\crossgen" )
36
+ DownloadNupkg " https://www.nuget.org/api/v2/package/Microsoft.Build.Tasks.Core/15.1.1012" @ (" lib\netstandard1.3\Microsoft.Build.Tasks.Core.dll" ) @ (" $selfContained " )
37
+ DownloadNupkg " https://www.nuget.org/api/v2/package/Microsoft.Build.Utilities.Core/15.1.1012" @ (" lib\netstandard1.3\Microsoft.Build.Utilities.Core.dll" ) @ (" $selfContained " )
38
+
39
+ # Publish self-contained app with all required dlls for crossgen
40
+ dotnet publish .\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj - r $runtime - o " $selfContained " - v q / p:BuildNumber= $buildNumber
41
+
42
+ # For self contained we want to process only IL ddls
43
+ if ($isSelfContained ) {
44
+ dotnet publish .\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj - o $regular - v q / p:BuildNumber= $buildNumber
45
+ }
46
+
47
+ $successfullDlls = @ ()
48
+ $failedDlls = @ ()
49
+ Get-ChildItem $privateSiteExtensionPath - Filter * .dll |
50
+ Foreach-Object {
51
+
52
+ # For self contained we want to process only IL ddls
53
+ if ($isSelfContained ) {
54
+ if (-Not [System.IO.File ]::Exists($ (Join-Path $regular $_.Name ))) {
55
+ Write-Host " Skipping $_ .Name"
56
+ Return
57
+ }
58
+ }
59
+
60
+ $prm = " /JITPath" , " $publishTarget \download\clrjit\clrjit.dll" , " /Platform_Assemblies_Paths" , " $selfContained " , " /nologo" , " /in" , $_.FullName
61
+ # output for Microsoft.Azure.WebJobs.Script.WebHost.dll is Microsoft.Azure.WebJobs.Script.WebHost.exe.dll by default
62
+ if ($_.FullName -like " *Microsoft.Azure.WebJobs.Script.WebHost.dll" ) {
63
+ $prm += " /out"
64
+ $prm += Join-Path $privateSiteExtensionPath " Microsoft.Azure.WebJobs.Script.WebHost.ni.dll"
65
+ }
66
+
67
+ & $crossGen $prm
68
+
69
+ $niDll = Join-Path $privateSiteExtensionPath $ ([io.path ]::GetFileNameWithoutExtension($_.FullName ) + " .ni.dll" )
70
+ if ([System.IO.File ]::Exists($niDll )) {
71
+ Remove-Item $_.FullName
72
+ Rename-Item - Path $niDll - NewName $_.FullName
73
+ $successfullDlls += [io.path ]::GetFileName($_.FullName )
74
+ } else {
75
+ $failedDlls += [io.path ]::GetFileName($_.FullName )
76
+ }
77
+ }
78
+
79
+ # print results of crossgen process
80
+ $successfullDllsCount = $successfullDlls.length
81
+ $failedDllsCount = $failedDlls.length
82
+ Write-Host " CrossGen($runtime ) results: Successfull: $successfullDllsCount , Failed: $failedDllsCount "
83
+ if ($failedDlls.length -gt 0 ) {
84
+ Write-Host " Failed CrossGen dlls:"
85
+ Write-Host $failedDlls
86
+ }
87
+
88
+
89
+ if (-Not $isSelfContained ) {
90
+ Copy-Item - Path $privateSiteExtensionPath \runtimes\win\native\* - Destination $privateSiteExtensionPath - Force
91
+ }
92
+
93
+ # read-host "Press ENTER to continue..."
94
+ Remove-Item - Recurse - Force $selfContained - ErrorAction SilentlyContinue
95
+ }
96
+
97
+ function DownloadNupkg ([string ] $nupkgPath , [string []]$from , [string []]$to ) {
98
+ $tempFolderName = [System.IO.Path ]::GetFileNameWithoutExtension([System.IO.Path ]::GetTempFileName())
99
+ $tempFolder = [System.IO.Path ]::Combine([System.IO.Path ]::GetTempPath() , $tempFolderName )
100
+ [System.IO.Directory ]::CreateDirectory($tempFolder )
101
+ Remove-Item $tempFolder
102
+ $tempFile = [System.IO.Path ]::GetTempFileName() |
103
+ Rename-Item - NewName { $_ -replace ' tmp$' , ' zip' } - PassThru
104
+
105
+ Write-Host " Downloading '$nupkgPath ' to '$tempFile '"
106
+ Invoke-WebRequest - Uri $nupkgPath - OutFile $tempFile
107
+ Write-Host " Extracting from '$tempFile ' to '$tempFolder '"
108
+ Add-Type - AssemblyName System.IO.Compression.FileSystem
109
+ [System.IO.Compression.ZipFile ]::ExtractToDirectory($tempFile , $tempFolder )
110
+
111
+ # copy nupkg files
112
+ for ($i = 0 ; $i -lt $from.length ; $i ++ ) {
113
+ New-Item $to - Type Directory - Force
114
+ Copy-Item - Path $ (" $tempFolder \" + $from [$i ]) - Destination $ ($to [$i ] + " \" ) - Force - Verbose
115
+ }
116
+ }
117
+
118
+
119
+ function BuildPackages ([string ] $runtime , [bool ] $isSelfContained ) {
120
+ $runtimeSuffix = " "
121
+ if (! [string ]::IsNullOrEmpty($runtime )) {
122
+ $runtimeSuffix = " .$runtime "
123
+ }
124
+
125
+ $publishTarget = " $buildOutput \publish$runtimeSuffix "
126
+ $siteExtensionPath = " $publishTarget \SiteExtensions"
127
+ $privateSiteExtensionPath = " $siteExtensionPath \Functions"
128
+
129
+ if ($isSelfContained ) {
130
+ dotnet publish .\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj - r $runtime - o " $privateSiteExtensionPath " - v q / p:BuildNumber= $buildNumber
131
+ } else {
132
+ dotnet publish .\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj - o " $privateSiteExtensionPath " - v q / p:BuildNumber= $buildNumber
133
+ }
134
+
135
+ # replace IL dlls with crossgen dlls
136
+ if (! [string ]::IsNullOrEmpty($runtime )) {
137
+ CrossGen $runtime $isSelfContained $publishTarget $privateSiteExtensionPath
138
+ }
139
+
140
+ ZipContent $privateSiteExtensionPath " $buildOutput \Functions.Binaries.$extensionVersion -alpha$runtimeSuffix .zip"
141
+
142
+ # Project cleanup (trim some project files - this should be revisited)
143
+ Remove-Item - Recurse - Force " $privateSiteExtensionPath \publish" - ErrorAction SilentlyContinue
144
+ Remove-Item - Recurse - Force " $privateSiteExtensionPath \runtimes\linux" - ErrorAction SilentlyContinue
145
+ Remove-Item - Recurse - Force " $privateSiteExtensionPath \runtimes\osx" - ErrorAction SilentlyContinue
146
+
147
+ # Create site extension packages
148
+ ZipContent $publishTarget " $buildOutput \Functions.Private.$extensionVersion -alpha$runtimeSuffix .zip"
149
+
150
+ # Build site extension
151
+ Write-Host " privateSiteExtensionPath: " $privateSiteExtensionPath
152
+ Rename-Item " $privateSiteExtensionPath " " $siteExtensionPath \$extensionVersion -alpha"
153
+ Copy-Item .\src\WebJobs.Script.WebHost\extension.xml " $siteExtensionPath "
154
+ ZipContent $siteExtensionPath " $buildOutput \Functions.$extensionVersion -alpha$runtimeSuffix .zip"
155
+
156
+ }
157
+
25
158
dotnet -- version
26
159
dotnet build .\WebJobs.Script.sln - v q / p:BuildNumber= " $buildNumber "
27
160
dotnet pack src\WebJobs.Script\WebJobs.Script.csproj - o ..\..\buildoutput -- no- build -- version- suffix $versionSuffix
28
161
dotnet pack src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj - o ..\..\buildoutput -- no- build -- version- suffix $versionSuffix
29
162
dotnet pack src\WebJobs.Script.Grpc\WebJobs.Script.Grpc.csproj - o ..\..\buildoutput -- no- build -- version- suffix $versionSuffix
30
163
31
- dotnet publish .\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj - o " $privateSiteExtensionPath " - v q / p:BuildNumber= $buildNumber
32
-
33
- # Create full binares package
34
- ZipContent $privateSiteExtensionPath " $buildoutput \Functions.Binaries.$extensionVersion -alpha.zip"
35
-
36
- # Project cleanup (trim some project files - this should be revisited)
37
- Remove-Item - Recurse - Force " $privateSiteExtensionPath \publish" - ErrorAction SilentlyContinue
38
- Remove-Item - Recurse - Force " $privateSiteExtensionPath \runtimes\linux" - ErrorAction SilentlyContinue
39
- Remove-Item - Recurse - Force " $privateSiteExtensionPath \runtimes\osx" - ErrorAction SilentlyContinue
40
164
41
- # Create site extension packages
42
- ZipContent $publishTarget " $buildoutput \Functions.Private. $extensionVersion -alpha.zip "
165
+ # build IL extensions
166
+ BuildPackages " " $false
43
167
44
- # Build site extension
45
- Rename-Item " $privateSiteExtensionPath " " $siteExtensionPath \$extensionVersion -alpha"
46
- Copy-Item .\src\WebJobs.Script.WebHost\extension.xml " $siteExtensionPath "
47
- ZipContent $siteExtensionPath " $buildoutput \Functions.$extensionVersion -alpha.zip"
168
+ # build win-x86 extensions
169
+ BuildPackages " win-x86" $false
0 commit comments