forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowsai-steps.yml
180 lines (157 loc) · 10.3 KB
/
windowsai-steps.yml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
parameters:
- name: BuildArch
displayName: BuildArch
type: string
default: 'x64'
- name: Runtime
displayName: MSVC Runtime, should be 'dynamic' or 'static'.
type: string
default: 'dynamic'
- name: PythonPackageName
displayName: PythonPackageName on nuget.org to use
type: string
default: 'python'
jobs:
- job: Windows_Packaging_${{ parameters.BuildArch }}_${{ parameters.Runtime }}
pool:
type: windows
variables:
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
ob_sdl_binskim_break: true
ob_sdl_binskim_scanOutputDirectoryOnly: true
steps:
- task: UseDotNet@2
inputs:
version: '5.x'
- template: ../tools/ci_build/github/azure-pipelines/templates/telemetry-steps.yml@self
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
feedsToUse: config
nugetConfigPath: NuGet.config
restoreDirectory: '$(Build.BinariesDirectory)'
${{ if eq(parameters.BuildArch, 'x64') }}:
restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x64\packages.config
${{ if eq(parameters.BuildArch, 'x86') }}:
restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x86\packages.config
${{ if eq(parameters.BuildArch, 'arm') }}:
restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x64\packages.config
${{ if eq(parameters.BuildArch, 'arm64') }}:
restoreSolution: $(Build.SourcesDirectory)\.pipelines\nuget_config\x64\packages.config
- script: |
@echo off
set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do (
set vslatest="%%i"
if exist "%%i\Common7\Tools\vsdevcmd.bat" (
set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat"
)
)
@echo vslatest %vslatest%
@echo vsdevcmd %vsdevcmd%
@echo ##vso[task.setvariable variable=vslatest]%vslatest%
@echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd% -arch=${{ parameters.BuildArch }}
displayName: 'locate vsdevcmd via vswhere'
- powershell: |
Write-Host "##vso[task.setvariable variable=BuildFlags]"
Write-Host "##vso[task.setvariable variable=ArtifactName]Microsoft.AI.MachineLearning.${{ parameters.BuildArch }}"
displayName: Initialize build flags
- powershell: |
Write-Host "##vso[task.setvariable variable=BuildFlags]$(BuildFlags) --${{ parameters.BuildArch }}"
displayName: Add cross compilation flags for ARM
condition: and(ne('${{ parameters.BuildArch }}', 'x64'), ne('${{ parameters.BuildArch }}', 'x86'))
- powershell: |
Write-Host "##vso[task.setvariable variable=BuildFlags]$(BuildFlags) --enable_msvc_static_runtime"
Write-Host "##vso[task.setvariable variable=ArtifactName]$(ArtifactName).StaticRuntime"
displayName: Add static runtime flags
condition: eq('${{ parameters.Runtime }}', 'static')
# must call vsdevcmd first to add cmake to PATH
- script: |
curl -O -L https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-windows-x86_64.zip
7z x cmake-3.28.3-windows-x86_64.zip
set PYTHONHOME=$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools
set PYTHONPATH=$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools
$(Build.BinariesDirectory)\${{ parameters.PythonPackageName }}.3.9.7\tools\python.exe "$(Build.SourcesDirectory)\tools\ci_build\build.py" --build_dir $(Build.BinariesDirectory) --parallel --use_binskim_compliant_compile_flags --build_shared_lib --enable_onnx_tests --ms_experimental --use_dml --use_winml --cmake_generator "Visual Studio 17 2022" --update --config RelWithDebInfo --enable_lto --use_telemetry --disable_rtti --enable_wcos --windows_sdk_version "10.0.22621.0" $(BuildFlags) --cmake_extra_defines "CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=/PROFILE" "CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO=/PROFILE" --cmake_path $(Build.BinariesDirectory)\cmake-3.28.3-windows-x86_64\bin\cmake.exe --ctest_path $(Build.BinariesDirectory)\cmake-3.28.3-windows-x86_64\bin\ctest.exe
workingDirectory: '$(Build.BinariesDirectory)'
displayName: 'Generate cmake config'
- task: VSBuild@1
displayName: 'Build'
inputs:
solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln'
${{ if ne(parameters.BuildArch, 'x86') }}:
platform: ${{ parameters.BuildArch }}
${{ if eq(parameters.BuildArch, 'x86') }}:
platform: 'Win32'
configuration: RelWithDebInfo
msbuildArchitecture: ${{ parameters.BuildArch }}
maximumCpuCount: true
logProjectEvents: true
workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo'
createLogFile: true
- ${{ if eq(parameters.Runtime, 'dynamic') }}:
- script: |
xcopy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\winml_test_api.exe $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\winml_test_scenario.exe $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\winml\test\api\models\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\winml\test\scenario\cppwinrt\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\winml\test\scenario\models\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\winml\test\common\testdata\squeezenet\* $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\winml\test\collateral\models\*.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
xcopy $(Build.SourcesDirectory)\winml\test\collateral\models\ModelSubdirectory $(Build.ArtifactStagingDirectory)\test_artifact\ModelSubdirectory\ /i
copy $(Build.SourcesDirectory)\winml\test\collateral\images\*.png $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\winml\test\collateral\images\*.jpg $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\onnxruntime\test\testdata\sequence_length.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
copy $(Build.SourcesDirectory)\onnxruntime\test\testdata\sequence_construct.onnx $(Build.ArtifactStagingDirectory)\test_artifact\
displayName: 'Copy WinML test collateral to artifact directory'
- ${{ if eq(parameters.BuildArch, 'x64') }}:
- script: |
call $(vsdevcmd)
msbuild Microsoft.AI.MachineLearning.Interop.csproj /p:Configuration=RelWithDebInfo /p:Platform="Any CPU" /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) -restore
workingDirectory: '$(Build.SourcesDirectory)\csharp\src\Microsoft.AI.MachineLearning.Interop'
displayName: 'Build Microsoft.AI.MachineLearning.Interop.dll'
- task: onebranch.pipeline.signing@1
inputs:
command: 'sign'
signing_profile: 'external_distribution'
files_to_sign: '**/*.exe;**/*.dll'
search_root: '$(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo'
displayName: 'Sign runtime DLLs'
- ${{ if eq(parameters.BuildArch, 'x64') }}:
- script: |
call $(vsdevcmd)
msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory)
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
workingDirectory: '$(Build.SourcesDirectory)\csharp'
displayName: 'Create NuGet Package'
- ${{ if eq(parameters.BuildArch, 'x86') }}:
- script: |
call $(vsdevcmd)
msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=x86
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
workingDirectory: '$(Build.SourcesDirectory)\csharp'
displayName: 'Create NuGet Package'
- ${{ if eq(parameters.BuildArch, 'arm64') }}:
- script: |
call $(vsdevcmd)
msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm64 /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
workingDirectory: '$(Build.SourcesDirectory)\csharp'
displayName: 'Create NuGet Package'
- ${{ if eq(parameters.BuildArch, 'arm') }}:
- script: |
call $(vsdevcmd)
msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory)
copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory)
workingDirectory: '$(Build.SourcesDirectory)\csharp'
displayName: 'Create NuGet Package'
- task: onebranch.pipeline.signing@1
inputs:
command: 'sign'
signing_profile: 'external_distribution'
files_to_sign: '**/*.exe;**/*.dll'
search_root: '$(Build.ArtifactStagingDirectory)\test_artifact'
displayName: 'Sign test_artifact'