mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
* Fix nuget content * Revert "Fix nuget content" This reverts commit e2cdcec4e39964c50eac2fb306c7a4bb84352443. * Nuget packaging * skip tests * msbuild path * Force msbuild version * Workaround https://github.com/NuGet/Home/issues/7621 * cleanup
278 lines
12 KiB
YAML
278 lines
12 KiB
YAML
parameters:
|
|
DoDebugBuild: 'true' # Unused. Use BuildConfigurations instead.
|
|
DoCompliance: 'false'
|
|
BuildCommand: ''
|
|
JobName: 'Windows_CI_Dev'
|
|
BuildCSharp: 'true'
|
|
DoNugetPack: 'false'
|
|
NuPackScript : ''
|
|
ArtifactName: 'drop-nuget'
|
|
DoNodejsPack: 'false'
|
|
DoEsrp: 'false'
|
|
DoTestCoverage: 'false'
|
|
BuildArch: 'x64' # Optional. Options: x86, x64
|
|
sln_platform: 'x64' # Options: Win32, x64, arm, arm64
|
|
EnvSetupScript: 'setup_env.bat'
|
|
CudaVersion: ''
|
|
AgentPool: 'Win-CPU-2019'
|
|
AgentDemands: []
|
|
OrtPackageId: Microsoft.ML.OnnxRuntime
|
|
BuildConfigurations: ['RelWithDebInfo'] # Options: Debug, RelWithDebInfo
|
|
RunTests : 'true'
|
|
EnableLto: true
|
|
# Controls whether unreleased onnx opsets are allowed. Default is set to 1
|
|
AllowReleasedOpsetOnly: '0'
|
|
jobs:
|
|
- job: ${{ parameters.JobName }}
|
|
timeoutInMinutes: 160
|
|
strategy:
|
|
maxParallel: 2
|
|
matrix:
|
|
${{ each BuildConfiguration in parameters.BuildConfigurations }}:
|
|
${{ BuildConfiguration }}:
|
|
BuildConfig: ${{ BuildConfiguration }}
|
|
workspace:
|
|
clean: all
|
|
pool:
|
|
name: ${{ parameters.AgentPool }}
|
|
demands: ${{ parameters.AgentDemands }}
|
|
variables:
|
|
buildDirectory: '$(Build.BinariesDirectory)'
|
|
BuildCommand: ${{ parameters.BuildCommand }}
|
|
OnnxRuntimeBuildDirectory: '$(Build.BinariesDirectory)'
|
|
DotNetExe: 'dotnet.exe'
|
|
CUDA_VERSION: ${{ parameters.CudaVersion }}
|
|
runCodesignValidationInjection: and(${{ parameters.DoNodejsPack }},${{ parameters. DoEsrp}}) #For the others, code sign is in a separated job
|
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
|
ALLOW_RELEASED_ONNX_OPSET_ONLY: ${{ parameters.AllowReleasedOpsetOnly }}
|
|
${{ if eq(parameters.EnableLto, true) }}:
|
|
build_py_lto_flag: --enable_lto
|
|
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
submodules: recursive
|
|
|
|
- powershell: |
|
|
if($env:TELEMETRYGUID)
|
|
{
|
|
$length = $env:TELEMETRYGUID.length
|
|
$fileContent = "#define TraceLoggingOptionMicrosoftTelemetry() \
|
|
TraceLoggingOptionGroup("+$env:TELEMETRYGUID.substring(1, $length-2)+")"
|
|
New-Item -Path "$(Build.SourcesDirectory)\include\onnxruntime\core\platform\windows\TraceLoggingConfigPrivate.h" -ItemType "file" -Value "$fileContent" -Force
|
|
Write-Output "Enabling TELEMETRY"
|
|
}
|
|
displayName: 'Create TraceLoggingConfigPrivate.h For WinML Telemetry'
|
|
env:
|
|
TELEMETRYGUID: $(TELEMETRYGUID)
|
|
|
|
- task: NodeTool@0
|
|
inputs:
|
|
versionSpec: '12.x'
|
|
|
|
- task: UsePythonVersion@0
|
|
inputs:
|
|
versionSpec: '3.7'
|
|
addToPath: true
|
|
architecture: ${{ parameters.BuildArch }}
|
|
|
|
- task: BatchScript@1
|
|
displayName: 'setup env'
|
|
inputs:
|
|
filename: '$(Build.SourcesDirectory)\tools\ci_build\github\windows\${{ parameters.EnvSetupScript }}'
|
|
modifyEnvironment: true
|
|
workingFolder: '$(Build.BinariesDirectory)'
|
|
|
|
- script: |
|
|
python -m pip install -q pyopenssl setuptools wheel numpy
|
|
workingDirectory: '$(Build.BinariesDirectory)'
|
|
displayName: 'Install python modules'
|
|
|
|
- powershell: |
|
|
$Env:USE_MSVC_STATIC_RUNTIME=1
|
|
$Env:ONNX_ML=1
|
|
$Env:CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ parameters.BuildArch }}-windows-static"
|
|
python setup.py bdist_wheel
|
|
Get-ChildItem -Path dist/*.whl | foreach {pip --disable-pip-version-check install --upgrade $_.fullname}
|
|
workingDirectory: '$(Build.SourcesDirectory)\cmake\external\onnx'
|
|
displayName: 'Install ONNX'
|
|
|
|
- task: PythonScript@0
|
|
displayName: 'Generate cmake config'
|
|
inputs:
|
|
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
|
|
arguments: '$(BuildCommand) --update --config $(BuildConfig) ${{ variables.build_py_lto_flag }}'
|
|
workingDirectory: '$(Build.BinariesDirectory)'
|
|
|
|
- ${{ if notIn(parameters['sln_platform'], 'Win32', 'x64') }}:
|
|
# Use cross-compiled protoc
|
|
- script: |
|
|
@echo ##vso[task.setvariable variable=ProtocDirectory]$(Build.BinariesDirectory)\host_protoc\Release
|
|
|
|
- task: VSBuild@1
|
|
displayName: 'Build'
|
|
inputs:
|
|
solution: '$(Build.BinariesDirectory)\$(BuildConfig)\onnxruntime.sln'
|
|
platform: ${{ parameters.sln_platform }}
|
|
configuration: $(BuildConfig)
|
|
msbuildArchitecture: ${{ parameters.BuildArch }}
|
|
maximumCpuCount: true
|
|
logProjectEvents: true
|
|
workingFolder: '$(Build.BinariesDirectory)\$(BuildConfig)'
|
|
createLogFile: true
|
|
|
|
# The Configuration variable is required to build C#
|
|
- ${{ if eq(parameters.BuildCSharp, true) }}:
|
|
- script: |
|
|
@echo ##vso[task.setvariable variable=Configuration]$(BuildConfig)
|
|
displayName: 'Set Configuration variable'
|
|
|
|
- template: set-test-data-variables-step.yml
|
|
|
|
- ${{ if eq(parameters.BuildCSharp, true) }}:
|
|
- task: NuGetToolInstaller@0
|
|
displayName: Use Nuget 5.7.0
|
|
inputs:
|
|
versionSpec: 5.7.0
|
|
|
|
- ${{ if eq(parameters.BuildCSharp, true) }}:
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Restore nuget packages'
|
|
inputs:
|
|
command: restore
|
|
projects: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
|
|
configuration: '$(BuildConfig)'
|
|
arguments: '--configuration $(BuildConfig) -p:Platform="Any CPU" -p:OrtPackageId=${{ parameters.OrtPackageId }}'
|
|
workingDirectory: '$(Build.SourcesDirectory)\csharp'
|
|
|
|
- ${{ if eq(parameters.BuildCSharp, true) }}:
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Build C#'
|
|
inputs:
|
|
command: build
|
|
projects: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
|
|
configuration: '$(BuildConfig)'
|
|
arguments: '--configuration $(BuildConfig) -p:Platform="Any CPU" -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=${{ parameters.OrtPackageId }}'
|
|
workingDirectory: '$(Build.SourcesDirectory)\csharp'
|
|
|
|
- ${{ if in(parameters['sln_platform'], 'Win32', 'x64') }}:
|
|
- ${{ if eq(parameters.BuildCSharp, true) }}:
|
|
- task: DotNetCoreCLI@2
|
|
displayName: 'Test C#'
|
|
inputs:
|
|
command: test
|
|
projects: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests\Microsoft.ML.OnnxRuntime.Tests.csproj'
|
|
configuration: '$(BuildConfig)'
|
|
arguments: '--configuration $(BuildConfig) -p:Platform="Any CPU" -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=${{ parameters.OrtPackageId }}'
|
|
workingDirectory: '$(Build.SourcesDirectory)\csharp'
|
|
|
|
- ${{ if eq(parameters.RunTests, true) }}:
|
|
- script: |
|
|
mklink /D /J $(Build.BinariesDirectory)\$(BuildConfig)\models $(Build.BinariesDirectory)\models
|
|
DIR dist\ /S /B > wheel_filename_file
|
|
set /p WHEEL_FILENAME=<wheel_filename_file
|
|
del wheel_filename_file
|
|
python.exe -m pip install -q --upgrade %WHEEL_FILENAME%
|
|
set PATH=%PATH%;$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)
|
|
@echo %PATH%
|
|
python $(Build.SourcesDirectory)\tools\ci_build\build.py $(BuildCommand) --test --config $(BuildConfig) ${{ variables.build_py_lto_flag }}
|
|
workingDirectory: '$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)'
|
|
displayName: 'Run tests'
|
|
|
|
- ${{ if eq(parameters.RunTests, true) }}:
|
|
- task: PublishTestResults@2
|
|
displayName: 'Publish unit test results'
|
|
inputs:
|
|
testResultsFiles: '**\*.results.xml'
|
|
searchFolder: '$(Build.BinariesDirectory)'
|
|
testRunTitle: 'Unit Test Run'
|
|
condition: succeededOrFailed()
|
|
|
|
# Nuget packaging if needed
|
|
- ${{ if and(eq(parameters.BuildCSharp, true), eq(parameters['DoNugetPack'], 'true')) }}:
|
|
- task: BatchScript@1
|
|
displayName: 'Setup VS2019 env vars'
|
|
inputs:
|
|
filename: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
|
|
arguments: ${{ parameters.BuildArch }}
|
|
modifyEnvironment: true
|
|
# Esrp signing
|
|
- template: win-esrp-dll.yml
|
|
parameters:
|
|
FolderPath: '$(Build.BinariesDirectory)\$(BuildConfig)\$(BuildConfig)'
|
|
DisplayName: 'ESRP - Sign Native dlls'
|
|
DoEsrp: ${{ parameters.DoEsrp }}
|
|
Pattern: 'onnx_test_runner.exe, onnxruntime_perf_test.exe,*.dll' #keep sync with src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
|
|
|
|
- template: win-esrp-dll.yml
|
|
parameters:
|
|
FolderPath: '$(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\bin\$(BuildConfig)'
|
|
DisplayName: 'ESRP - Sign C# dlls'
|
|
DoEsrp: ${{ parameters.DoEsrp }}
|
|
|
|
- script: |
|
|
${{ parameters.NuPackScript }}
|
|
workingDirectory: '$(Build.SourcesDirectory)\csharp'
|
|
displayName: 'Create NuGet Package'
|
|
|
|
- task: PublishPipelineArtifact@0
|
|
displayName: 'Publish Pipeline Artifact: ${{ parameters.ArtifactName }}'
|
|
inputs:
|
|
artifactName: ${{ parameters.ArtifactName }}
|
|
targetPath: '$(Build.ArtifactStagingDirectory)'
|
|
|
|
- task: PublishSymbols@2
|
|
displayName: 'Publish Build Symbols'
|
|
condition: eq(variables['IsReleaseBuild'], 'true')
|
|
inputs:
|
|
symbolsFolder: '$(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo'
|
|
searchPattern: '**/*.pdb'
|
|
symbolServerType: teamServices
|
|
|
|
# Node.js Publish
|
|
- ${{ if eq(parameters['DoNodejsPack'], 'true') }}:
|
|
- task: BatchScript@1
|
|
displayName: 'Setup VS2019 env vars'
|
|
inputs:
|
|
filename: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
|
|
arguments: ${{ parameters.BuildArch }}
|
|
modifyEnvironment: true
|
|
- template: win-esrp-dll.yml
|
|
parameters:
|
|
FolderPath: '$(Build.SourcesDirectory)\nodejs\bin\napi-v3\win32\x64'
|
|
DisplayName: 'ESRP - Sign Node.js binding binaries'
|
|
DoEsrp: ${{ parameters.DoEsrp }}
|
|
Pattern: '*.dll,*.node'
|
|
|
|
- script: |
|
|
del /Q $(Build.SourcesDirectory)\nodejs\bin\napi-v3\win32\x64\CodeSignSummary-*.*
|
|
call npm pack
|
|
copy $(Build.SourcesDirectory)\nodejs\onnxruntime-*.tgz $(Build.ArtifactStagingDirectory)
|
|
xcopy /E /I $(Build.SourcesDirectory)\nodejs\prebuilds $(Build.ArtifactStagingDirectory)\prebuilds
|
|
workingDirectory: '$(Build.SourcesDirectory)\nodejs'
|
|
displayName: 'Create NPM Package'
|
|
|
|
- task: PublishPipelineArtifact@0
|
|
displayName: 'Publish Pipeline Artifact: ${{ parameters.ArtifactName }}'
|
|
inputs:
|
|
artifactName: ${{ parameters.ArtifactName }}
|
|
targetPath: '$(Build.ArtifactStagingDirectory)'
|
|
|
|
# Put an unzipped version there to check if all the binaries are signed.
|
|
- script: |
|
|
7z x $(Build.ArtifactStagingDirectory)\prebuilds\onnxruntime-*.tar.gz
|
|
7z x $(Build.ArtifactStagingDirectory)\onnxruntime-*.tar
|
|
displayName: 'Unzip package to test'
|
|
workingDirectory: '$(Build.ArtifactStagingDirectory)'
|
|
|
|
# Compliance tasks require logs from Debug Build
|
|
- ${{ if eq(parameters['DoCompliance'], 'true') }}:
|
|
- template: compliance.yml
|
|
|
|
- template: component-governance-component-detection-steps.yml
|
|
parameters :
|
|
condition : 'succeeded'
|
|
|
|
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
|
|
displayName: 'Clean Agent Directories'
|
|
condition: always()
|