Skip to content

Commit

Permalink
Set version and other info in the C# dll (#21517)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe your changes. -->
Set version and other info in the Microsoft.ML.OnnxRuntime C# dll by
setting GenerateAssemblyInfo to true and passing in ORT version in the
CI.

Minor re-org of the order of properties so related things are grouped a
little better.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
#21475
  • Loading branch information
skottmckay authored Jul 27, 2024
1 parent 64819f6 commit 5af423c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
67 changes: 39 additions & 28 deletions csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,51 @@
</PropertyGroup>

<PropertyGroup Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training' AND
'$(IncludeMobileTargets)' == 'true'">
'$(IncludeMobileTargets)' == 'true'">
<MobileTargets>net8.0-android</MobileTargets>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>$(BaseTargets);$(MobileTargets)</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<RootNamespace>Microsoft.ML.OnnxRuntime</RootNamespace>
<AssemblyName>Microsoft.ML.OnnxRuntime</AssemblyName>

<!-- Ignore any passed in value unless this is a release build. -->
<PackageVersion Condition="'$(IsReleaseBuild)' != 'true'"></PackageVersion>
<PackageVersion Condition="'$(PackageVersion)' == '' And '$(Configuration)' == 'Debug'">1.0.0</PackageVersion>
<PackageVersion Condition="'$(PackageVersion)' == '' ">0.0.0</PackageVersion>

<!-- Set the attributes for the managed dll -->
<!-- https://learn.microsoft.com/en-us/dotnet/standard/assembly/set-attributes-project-file -->
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<AssemblyTitle>Microsoft.ML.OnnxRuntime C# Bindings</AssemblyTitle>
<Company>Microsoft</Company>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<Description>This package contains ONNX Runtime for .Net platforms</Description>

<!-- NOTE: this is also used as the default for AssemblyVersion and FileVersion -->
<Version>$(PackageVersion)</Version>

<!-- Set the attributes for a nuget package -->
<!--- The package name is always hardcoded as the package created by this project only contains managed assemblies -->
<!--- The parameter OrtPackageId is only used for some conditional logic below -->
<Authors>Microsoft</Authors>
<PackageId>Microsoft.ML.OnnxRuntime.Managed</PackageId>
<PackageTags>ONNX;ONNX Runtime;Machine Learning</PackageTags>
<PackageProjectUrl>https://github.com/Microsoft/onnxruntime</PackageProjectUrl>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIcon>ORT_icon_for_light_bg.png</PackageIcon>
<PackageReleaseNotes>
Release Def:
Branch: $(BUILD_SOURCEBRANCH)
Commit: $(BUILD_SOURCEVERSION)
Build: https://aiinfra.visualstudio.com/Lotus/_build/results?buildId=$(BUILD_BUILDID)
</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<Platforms>AnyCPU;x86</Platforms>
<LangVersion>default</LangVersion>
Expand All @@ -43,8 +80,6 @@
<OnnxRuntimeCsharpRoot>$(OnnxRuntimeRoot)\csharp</OnnxRuntimeCsharpRoot>
<TargetArchitecture Condition=" '$(TargetArchitecture)' == '' ">x64</TargetArchitecture>

<RootNamespace>Microsoft.ML.OnnxRuntime</RootNamespace>
<AssemblyName>Microsoft.ML.OnnxRuntime</AssemblyName>
<EnableDefaultItems>false</EnableDefaultItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DebugType>portable</DebugType>
Expand All @@ -54,35 +89,15 @@
on their device is not built for training, an exception will be thrown with the following message -
"Training is disabled in the current build. Please build onnxruntime from source with the build flags
enable_training_apis. "-->
<EnableTrainingApis Condition="'$(EnableTrainingApis)' == ''">true</EnableTrainingApis>
<EnableTrainingApis Condition="'$(EnableTrainingApis)' == ''">true</EnableTrainingApis>

<!--- The package name is always hardcoded as the package created by this project only contains managed assemblies -->
<!--- The parameter OrtPackageId is only used for some conditional logic below -->
<PackageId>Microsoft.ML.OnnxRuntime.Managed</PackageId>
<Authors>Microsoft</Authors>
<PackageVersion Condition=" '$(PackageVersion)' == '' And '$(Configuration)' == 'Debug' ">1.0.0</PackageVersion>
<PackageVersion Condition=" '$(PackageVersion)' == '' ">0.0.0</PackageVersion>
<Version>$(PackageVersion)</Version>
<Description>This package contains ONNX Runtime for .Net platforms</Description>
<PackageTags>ONNX;ONNX Runtime;Machine Learning</PackageTags>
<PackageProjectUrl>https://github.com/Microsoft/onnxruntime</PackageProjectUrl>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIcon>ORT_icon_for_light_bg.png</PackageIcon>
<PackageReleaseNotes>
Release Def:
Branch: $(BUILD_SOURCEBRANCH)
Commit: $(BUILD_SOURCEVERSION)
Build: https://aiinfra.visualstudio.com/Lotus/_build/results?buildId=$(BUILD_BUILDID)
</PackageReleaseNotes>
<!-- sourcelink flags -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>

<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
<!--EmbedUntrackedSources>true</EmbedUntrackedSources-->

<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<Configurations>Debug;Release;RelWithDebInfo</Configurations>

Expand Down Expand Up @@ -158,10 +173,6 @@
<OrtConstants>$(OrtConstants);__ENABLE_COREML__</OrtConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(IsXamarinTarget)'=='true'">
<OrtConstants>$(OrtConstants);__XAMARIN__</OrtConstants>
</PropertyGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);$(OrtConstants)</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ stages:
workingDirectory: '$(Build.BinariesDirectory)/nuget-artifact'
displayName: 'List artifacts'
- template: set-version-number-variables-step.yml

# Reconstruct the build dir
- task: PowerShell@2
displayName: 'Extract native libraries for addition to nuget native package'
Expand Down Expand Up @@ -403,7 +405,7 @@ stages:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
platform: 'Any CPU'
configuration: RelWithDebInfo
msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)'
msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion)'
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- ${{ if eq(parameters.DoEsrp, true) }}:
Expand Down

0 comments on commit 5af423c

Please sign in to comment.