Enable C# .NET5 for WinML (#6120)

* build for .net5

* only reference cswinrt for .net5

* remove netstandard2.0 references

* upgrade language version

* net5

* remove extra comment closure

* add targetframework

* set target framework

* remove net*

* pep8 errors

* make test project build with .net windows SDK projection

* disable c# builds for non-x64 builds

* fix pep8 errors

* disable for store build

* fix tests

* remove cswinrt and sdk references from package

* bump cswinrt down to 1.0.1

* fix bin path

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
This commit is contained in:
Sheil Kumar 2020-12-14 15:05:15 -08:00 committed by GitHub
parent eb5c1f0fcc
commit a6a23db130
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 64 additions and 486 deletions

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<ProjectName>Microsoft.AI.MachineLearning.Interop</ProjectName>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platform>Any CPU</Platform>
@ -12,12 +12,11 @@
<BuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</BuildOutputDir>
<WindowsAIInteropOutputDir>$(BuildOutputDir)\Microsoft.AI.MachineLearning.Interop</WindowsAIInteropOutputDir>
<OutputPath>$(WindowsAIInteropOutputDir)</OutputPath>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="0.1.0-prerelease.200629.3" targetFramework="net46" />
<PackageReference Include="Microsoft.Windows.SDK.NET" Version="10.0.18362.3-preview" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.0.1" targetFramework="net5.0-windows10.0.19041.0" />
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" targetFramework="net5.0-windows10.0.19041.0" />
</ItemGroup>
<ItemGroup>

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

View file

@ -1,4 +0,0 @@
# build, distribute, and bins (+ python proto bindings)
Debug
x64
packages

View file

@ -1,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2</RootNamespace>
<AssemblyName>Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AI.MachineLearning.Interop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.AI.MachineLearning.1.4.0-dev-20200728-0957-6cb93ccb5\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Windows.SDK.NET, Version=10.0.18362.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="winrt.runtime, Version=0.1.0.1677, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\lib\netstandard2.0\winrt.runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="main.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\testdata\squeezenet.onnx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets'))" />
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.4.0-dev-20200728-0957-6cb93ccb5\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.4.0-dev-20200728-0957-6cb93ccb5\build\netstandard2.0\Microsoft.AI.MachineLearning.targets'))" />
</Target>
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets')" />
<Import Project="packages\Microsoft.AI.MachineLearning.1.4.0-dev-20200728-0957-6cb93ccb5\build\netstandard2.0\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.4.0-dev-20200728-0957-6cb93ccb5\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" />
</Project>

View file

@ -1,111 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2</RootNamespace>
<AssemblyName>Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AI.MachineLearning.Interop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.AI.MachineLearning.[PackageVersion]\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Windows.SDK.NET, Version=10.0.18362.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="winrt.runtime, Version=0.1.0.1677, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\lib\netstandard2.0\winrt.runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="main.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\testdata\squeezenet.onnx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets'))" />
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets'))" />
</Target>
<Import Project="packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\build\Microsoft.Windows.CsWinRT.targets')" />
<Import Project="packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.[PackageVersion]\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" />
</Project>

View file

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1082
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2", "Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj", "{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|x64.ActiveCfg = Debug|x64
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|x64.Build.0 = Debug|x64
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|Any CPU.Build.0 = Release|Any CPU
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|x64.ActiveCfg = Release|x64
{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4998D043-F471-4AEC-9959-CCE3D27A444E}
EndGlobalSection
EndGlobal

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="NuGet Official" value="https://api.nuget.org/v3/index.json" />
<add key="BuildArtifacts" value="E:\nugets" />
</packageSources>
</configuration>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="NuGet Official" value="https://api.nuget.org/v3/index.json" />
<add key="BuildArtifacts" value="[BuildPackageSource]" />
</packageSources>
</configuration>

View file

@ -1,77 +0,0 @@
using System;
using System.IO;
using Microsoft.AI.MachineLearning;
using WinRT;
namespace Microsoft.AI.MachineLearning.Tests
{
class Program
{
static void PerformInference(Windows.Media.VideoFrame frame)
{
Console.WriteLine("Load squeezenet.onnx.");
using (var model = Microsoft.AI.MachineLearning.LearningModel.LoadFromFilePath("squeezenet.onnx"))
{
Console.WriteLine("Create LearningModelSession.");
using (var session = new Microsoft.AI.MachineLearning.LearningModelSession(model))
{
Console.WriteLine("Create LearningModelBinding.");
var binding = new Microsoft.AI.MachineLearning.LearningModelBinding(session);
Console.WriteLine("Bind data_0.");
binding.Bind("data_0", frame);
Console.WriteLine("Evaluate.");
var results = session.Evaluate(binding, "");
}
Console.WriteLine("Success!\n");
}
}
static void Main(string[] args)
{
Console.WriteLine("Load kitten_224.png as StorageFile.");
var name = AppDomain.CurrentDomain.BaseDirectory + "kitten_224.png";
var getFileFromPathTask = Windows.Storage.StorageFile.GetFileFromPathAsync(name);
getFileFromPathTask.AsTask()
.ContinueWith<Windows.Storage.Streams.IRandomAccessStreamWithContentType>(
(task) =>
{
var image = task.Result;
Console.WriteLine("Load StorageFile into Stream.");
var stream_task = image.OpenReadAsync();
// https://github.com/microsoft/CsWinRT/issues/335
return stream_task.AsTask().Result;
})
.ContinueWith<Windows.Graphics.Imaging.BitmapDecoder>(
(task) =>
{
using (var stream = task.Result)
{
Console.WriteLine("Create SoftwareBitmap from decoded Stream.");
var decoder_task = Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
// https://github.com/microsoft/CsWinRT/issues/335
return decoder_task.AsTask().Result;
}
})
.ContinueWith<Windows.Graphics.Imaging.SoftwareBitmap>(
(task) =>
{
var decoder = task.Result;
var software_bitmap_task = decoder.GetSoftwareBitmapAsync();
// https://github.com/microsoft/CsWinRT/issues/335
return software_bitmap_task.AsTask().Result;
})
.ContinueWith(
(task) =>
{
using (var software_bitmap = task.Result)
{
Console.WriteLine("Create VideoFrame.");
var frame = Windows.Media.VideoFrame.CreateWithSoftwareBitmap(software_bitmap);
PerformInference(frame);
}
})
.Wait();
}
}
}

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AI.MachineLearning" version="1.4.0-dev-20200728-0957-6cb93ccb5" targetFramework="net472" />
<package id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200629.3" targetFramework="net472" />
<package id="Microsoft.Windows.SDK.NET" version="10.0.18362.3-preview" targetFramework="net472" />
</packages>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AI.MachineLearning" version="[PackageVersion]" targetFramework="net472" />
<package id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200629.3" targetFramework="net472" />
<package id="Microsoft.Windows.SDK.NET" version="10.0.18362.3-preview" targetFramework="net472" />
</packages>

View file

@ -576,89 +576,43 @@ jobs:
msbuild /p:Platform=x64 Microsoft.AI.MachineLearning.Tests.vcxproj
workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests
- task: PowerShell@2
displayName: 'NuGet Tests: Fix Nuget Package references (.NET FRAMEWORK 4.7.2)'
inputs:
targetType: 'inline'
script: |
Add-Type -AssemblyName "System.IO.Compression.FileSystem"
$src_root_dir = $Env:BUILD_SOURCESDIRECTORY;
$artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY;
$merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged')
$nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*)
$merged_nuget_package = $nupkgs[0]
$merged_nuget_package_name = $merged_nuget_package.Name
$matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?<version>.*).nupkg")
$package_version = $matches['version']
$src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2')
$input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj.pp')
$csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj')
$packages_dir = [System.IO.Path]::Combine($src_dir, 'packages')
$input_csproj_content = Get-Content -Path $input_csproj
$csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version
Set-Content -Path $csproj -Value $csproj_content
$input_config = [System.IO.Path]::Combine($src_dir, 'packages.config.pp')
$output_config = [System.IO.Path]::Combine($src_dir, 'packages.config')
$input_config_content = Get-Content -Path $input_config
$output_config_content = $input_config_content -replace '\[PackageVersion\]', $package_version
Set-Content -Path $output_config -Value $output_config_content
nuget restore -PackagesDirectory $packages_dir -Source https://api.nuget.org/v3/index.json -Source $merged_nuget_path $csproj
- task: PowerShell@2
displayName: 'NuGet Tests: Fix Nuget Package references (.NET 5.0)'
inputs:
targetType: 'inline'
script: |
Add-Type -AssemblyName "System.IO.Compression.FileSystem"
$src_root_dir = $Env:BUILD_SOURCESDIRECTORY;
$artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY;
$merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged')
$nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*)
$merged_nuget_package = $nupkgs[0]
$merged_nuget_package_name = $merged_nuget_package.Name
$matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?<version>.*).nupkg")
$package_version = $matches['version']
$src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.DotNet5_0')
$input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj.pp')
$csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj')
$input_csproj_content = Get-Content -Path $input_csproj
$csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version
Set-Content -Path $csproj -Value $csproj_content
$input_nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config.pp')
$nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config')
$input_nuget_config_content = Get-Content -Path $input_nuget_config
$nuget_config_content = $input_nuget_config_content -replace '\[BuildPackageSource\]', $merged_nuget_path
Set-Content -Path $nuget_config -Value $nuget_config_content
workingDirectory: $(Build.ArtifactStagingDirectory)\merged
- task: PowerShell@2
displayName: 'NuGet Tests: Build Tests (C#)'
inputs:
targetType: 'inline'
script: |
msbuild Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj /p:Platform=AnyCpu
msbuild Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj /p:Platform=x64
workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2
- task: PowerShell@2
displayName: 'NuGet Tests: Fix Nuget Package references (.NET CORE 3.0)'
displayName: 'NuGet Tests: Build Tests (.NET 5.0)'
inputs:
targetType: 'inline'
script: |
Add-Type -AssemblyName "System.IO.Compression.FileSystem"
$src_root_dir = $Env:BUILD_SOURCESDIRECTORY;
$artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY;
$merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged')
$nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*)
$merged_nuget_package = $nupkgs[0]
$merged_nuget_package_name = $merged_nuget_package.Name
$matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?<version>.*).nupkg")
$package_version = $matches['version']
$src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.DotNetCore3_0')
$input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj.pp')
$csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj')
$input_csproj_content = Get-Content -Path $input_csproj
$csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version
Set-Content -Path $csproj -Value $csproj_content
$input_nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config.pp')
$nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config')
$input_nuget_config_content = Get-Content -Path $input_nuget_config
$nuget_config_content = $input_nuget_config_content -replace '\[BuildPackageSource\]', $merged_nuget_path
Set-Content -Path $nuget_config -Value $nuget_config_content
workingDirectory: $(Build.ArtifactStagingDirectory)\merged
- task: PowerShell@2
displayName: 'NuGet Tests: Build Tests (.NET CORE 3.0)'
inputs:
targetType: 'inline'
script: |
msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=x64 /t:Restore
msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=x64
msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=AnyCpu /t:Restore
msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=AnyCpu
workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.DotNetCore3_0
msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=x64 /t:Restore
msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=x64
msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=AnyCpu /t:Restore
msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=AnyCpu
workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.DotNet5_0
- task: PowerShell@2
displayName: 'NuGet Tests: Run Tests'
@ -675,19 +629,16 @@ jobs:
.\Microsoft.AI.MachineLearning.Tests.exe
popd
Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (DotNetCore3_0)"
pushd .\Microsoft.AI.MachineLearning.Tests.DotNetCore3_0\bin\x64\Debug\netcoreapp3.0
.\Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.exe
Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (DotNet5_0)"
pushd .\Microsoft.AI.MachineLearning.Tests.DotNet5_0\bin\Debug\net5.0-windows10.0.19041.0
.\Microsoft.AI.MachineLearning.Tests.DotNet5_0.exe
popd
Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (AnyCpu)"
pushd .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2\bin\Debug
.\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.exe
popd
Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (x64)"
pushd .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2\bin\x64\Debug
.\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.exe
pushd .\Microsoft.AI.MachineLearning.Tests.DotNet5_0\bin\x64\Debug\net5.0-windows10.0.19041.0
.\Microsoft.AI.MachineLearning.Tests.DotNet5_0.exe
popd
Write-Host "Done!"
workingDirectory: $(Build.SourcesDirectory)\csharp\test

View file

@ -185,10 +185,11 @@ steps:
${{ if eq(parameters.BuildArch, 'arm') }}:
arguments: 'x64'
modifyEnvironment: true
- script: 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'
- ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'false')) }}:
- script: 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'
# Esrp signing
- template: win-esrp-dll.yml

View file

@ -82,19 +82,8 @@ def generate_dependencies(list, package_name, version):
list.append('<dependencies>')
# Support .Net Core
list.append('<group targetFramework="NETCOREAPP">')
list.append('<dependency id="Microsoft.Windows.SDK.NET"' + ' version="10.0.18362.3-preview"/>')
list.append('<dependency id="Microsoft.Windows.CsWinRT"' + ' version="0.1.0-prerelease.200629.3"/>')
list.append('</group>')
# Support .Net Standard
list.append('<group targetFramework="NETSTANDARD">')
list.append('<dependency id="Microsoft.Windows.SDK.NET"' + ' version="10.0.18362.3-preview"/>')
list.append('<dependency id="Microsoft.Windows.CsWinRT"' + ' version="0.1.0-prerelease.200629.3"/>')
list.append('</group>')
# Support .Net Framework
list.append('<group targetFramework="NETFRAMEWORK">')
list.append('<dependency id="Microsoft.Windows.SDK.NET"' + ' version="10.0.18362.3-preview"/>')
list.append('<dependency id="Microsoft.Windows.CsWinRT"' + ' version="0.1.0-prerelease.200629.3"/>')
list.append('<group targetFramework="net5.0">')
list.append(dml_dependency)
list.append('</group>')
# UAP10.0.16299, This is the earliest release of the OS that supports .NET Standard apps
list.append('<group targetFramework="UAP10.0.16299">')
@ -289,12 +278,15 @@ def generate_files(list, args):
files_list.append('<file src=' + '"' + os.path.join(args.ort_build_path, args.build_config,
'microsoft.ai.machinelearning.winmd') +
'" target="lib\\uap\\Microsoft.AI.MachineLearning.winmd" />')
interop_dll = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.dll'
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, interop_dll) +
'" target="lib\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.dll" />')
interop_pdb = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.pdb'
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, interop_pdb) +
'" target="lib\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.pdb" />')
if args.target_architecture == 'x64' and not args.is_store_build:
interop_dll_path = 'Microsoft.AI.MachineLearning.Interop\\net5.0-windows10.0.19041.0'
interop_dll = interop_dll_path + '\\Microsoft.AI.MachineLearning.Interop.dll'
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, interop_dll) +
'" target="lib\\net5.0\\Microsoft.AI.MachineLearning.Interop.dll" />')
interop_pdb_path = 'Microsoft.AI.MachineLearning.Interop\\net5.0-windows10.0.19041.0'
interop_pdb = interop_pdb_path + '\\Microsoft.AI.MachineLearning.Interop.pdb'
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, interop_pdb) +
'" target="lib\\net5.0\\Microsoft.AI.MachineLearning.Interop.pdb" />')
# Process runtimes
# Process onnxruntime import lib, dll, and pdb
@ -408,11 +400,12 @@ def generate_files(list, args):
files_list.append('<file src=' + '"' + windowsai_native_targets + '" target="' + build + '" />')
# Process rules
files_list.append('<file src=' + '"' + windowsai_native_rules + '" target="' + build + '" />')
# Process .net standard 2.0 targets
interop_src = 'Microsoft.AI.MachineLearning.Interop'
interop_targets = 'Microsoft.AI.MachineLearning.targets'
windowsai_net20_targets = os.path.join(args.sources_path, 'csharp', 'src', interop_src, interop_targets)
files_list.append('<file src=' + '"' + windowsai_net20_targets + '" target="build\\netstandard2.0" />')
# Process .net5.0 targets
if args.target_architecture == 'x64' and not args.is_store_build:
interop_src = 'Microsoft.AI.MachineLearning.Interop'
interop_targets = 'Microsoft.AI.MachineLearning.targets'
windowsai_net50_targets = os.path.join(args.sources_path, 'csharp', 'src', interop_src, interop_targets)
files_list.append('<file src=' + '"' + windowsai_net50_targets + '" target="build\\net5.0" />')
if is_cpu_package or is_cuda_gpu_package or is_dml_package or is_mklml_package:
# Process props file