Add .NET Core 3.0 nuget e2e pipeline tests (#4695)

* bump cswinrt version

* add cswinrt

* test dotnetcore 3.0

* rename buildpacakge source

* set folder path to the package source and not the version

* refactor .netframework tests

* build .net core anycpu

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
This commit is contained in:
Sheil Kumar 2020-08-05 13:02:24 -07:00 committed by GitHub
parent eb0f57f0e4
commit 5c5efa900d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 371 additions and 140 deletions

View file

@ -12,10 +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.200512.7" targetFramework="net46" />
<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" />
</ItemGroup>
@ -25,7 +26,7 @@
<Target Name="GenerateProjection" BeforeTargets="DispatchToInnerBuilds;Build;CoreCompile">
<ConvertToAbsolutePath Paths="$(OnnxRuntimeBuildDirectory)">
<Output TaskParameter="AbsolutePaths" PropertyName="OnnxRuntimeBuildDirectoryAbs"/>
<Output TaskParameter="AbsolutePaths" PropertyName="OnnxRuntimeBuildDirectoryAbs" />
</ConvertToAbsolutePath>
<ItemGroup>
@ -36,8 +37,8 @@
<CsWinRTCommand>$(CsWinRTPath)cswinrt.exe -verbose -in local -in @(WindowsAIsWinMDs->'"%(FullPath)"', ' ') -out "$(ProjectDir)Generated Files" -include Microsoft.AI.MachineLearning</CsWinRTCommand>
</PropertyGroup>
<Message Text="Generating $(ProjectName) CS projection sources with command:"/>
<Message Text="$(CsWinRTCommand)"/>
<Message Text="Generating $(ProjectName) CS projection sources with command:" />
<Message Text="$(CsWinRTCommand)" />
<Exec Command="$(CsWinRTCommand)" />
<ItemGroup>

View file

@ -3,6 +3,8 @@
<PropertyGroup>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'x64' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' != 'true')">x64</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'x86' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' == 'true')">x86</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == '' AND '$(Prefer32Bit)' != 'true'">x64</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == '' AND '$(Prefer32Bit)' == 'true'">x86</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(WindowsAI-Platform)' == ''">$(PlatformTarget)</WindowsAI-Platform>
</PropertyGroup>

View file

@ -1,92 +0,0 @@
using System;
using System.IO;
using Microsoft.AI.MachineLearning;
using WinRT;
namespace Microsoft.AI.MachineLearning.Tests
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Load squeezenet.onnx.");
using (var model = LearningModel.LoadFromFilePath("squeezenet.onnx"))
{
Console.WriteLine("Load kitten_224.png as StorageFile.");
var name = AppDomain.CurrentDomain.BaseDirectory + "kitten_224.png";
var image_task = Windows.Storage.StorageFile.GetFileFromPathAsync(name);
image_task.AsTask().Wait();
var image = image_task.GetResults();
Console.WriteLine("Load StorageFile into Stream.");
var stream_task = image.OpenReadAsync();
System.Threading.Thread.Sleep(1000);
// stream_task.AsTask().Wait();
//
// Unable to call AsTask on IAsyncOperation<IRandomAccessStreamWithContentType>...
// System.TypeInitializationException: 'The type initializer for 'ABI.Windows.Foundation.AsyncOperationCompletedHandler`1' threw an exception.'
// This exception was originally thrown at this call stack:
// System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(System.RuntimeType)
// System.RuntimeType.SanityCheckGenericArguments(System.RuntimeType[], System.RuntimeType[])
// System.RuntimeType.MakeGenericType(System.Type[])
// System.Linq.Expressions.Compiler.DelegateHelpers.MakeNewDelegate(System.Type[])
// System.Linq.Expressions.Compiler.DelegateHelpers.MakeDelegateType(System.Type[])
// ABI.Windows.Foundation.AsyncOperationCompletedHandler<TResult>.AsyncOperationCompletedHandler()
//
// So sleep instead...
using (var stream = stream_task.GetResults())
{
Console.WriteLine("Create SoftwareBitmap from decoded Stream.");
var decoder_task = Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
System.Threading.Thread.Sleep(1000);
// decoder_task.AsTask().Wait();
//
// Unable to call AsTask on IAsyncOperation<SoftwareBitmap>...
// System.TypeInitializationException: 'The type initializer for 'ABI.Windows.Foundation.AsyncOperationCompletedHandler`1' threw an exception.'
// This exception was originally thrown at this call stack:
// System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(System.RuntimeType)
// System.RuntimeType.SanityCheckGenericArguments(System.RuntimeType[], System.RuntimeType[])
// System.RuntimeType.MakeGenericType(System.Type[])
// System.Linq.Expressions.Compiler.DelegateHelpers.MakeNewDelegate(System.Type[])
// System.Linq.Expressions.Compiler.DelegateHelpers.MakeDelegateType(System.Type[])
// ABI.Windows.Foundation.AsyncOperationCompletedHandler<TResult>.AsyncOperationCompletedHandler()
//
// So sleep instead...
var decoder = decoder_task.GetResults();
var software_bitmap_task = decoder.GetSoftwareBitmapAsync();
System.Threading.Thread.Sleep(1000);
// software_bitmap_task.AsTask().Wait();
//
// Unable to call AsTask on IAsyncOperation<SoftwareBitmap>...
// System.TypeInitializationException: 'The type initializer for 'ABI.Windows.Foundation.AsyncOperationCompletedHandler`1' threw an exception.'
// This exception was originally thrown at this call stack:
// System.RuntimeType.ThrowIfTypeNeverValidGenericArgument(System.RuntimeType)
// System.RuntimeType.SanityCheckGenericArguments(System.RuntimeType[], System.RuntimeType[])
// System.RuntimeType.MakeGenericType(System.Type[])
// System.Linq.Expressions.Compiler.DelegateHelpers.MakeNewDelegate(System.Type[])
// System.Linq.Expressions.Compiler.DelegateHelpers.MakeDelegateType(System.Type[])
// ABI.Windows.Foundation.AsyncOperationCompletedHandler<TResult>.AsyncOperationCompletedHandler()
//
// So sleep instead...
using (var software_bitmap = software_bitmap_task.GetResults())
{
Console.WriteLine("Create VideoFrame.");
var frame = Windows.Media.VideoFrame.CreateWithSoftwareBitmap(software_bitmap);
Console.WriteLine("Create LearningModelSession.");
using (var session = new LearningModelSession(model))
{
Console.WriteLine("Create LearningModelBinding.");
var binding = new LearningModelBinding(session);
Console.WriteLine("Bind data_0.");
binding.Bind("data_0", frame);
Console.WriteLine("Evaluate.");
var results = session.Evaluate(binding, "");
}
Console.WriteLine("Success!\n");
}
}
}
}
}
}

View file

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AI.MachineLearning" Version="1.4.0-dev-20200728-0957-6cb93ccb5" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\testdata\squeezenet.onnx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AI.MachineLearning" Version="[PackageVersion]" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\testdata\squeezenet.onnx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
<None Include="..\..\..\winml\test\collateral\images\kitten_224.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>true</Visible>
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,10 @@
<?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

@ -0,0 +1,10 @@
<?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

@ -0,0 +1,70 @@
using System;
namespace ConsoleApp17
{
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();
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);
return decoder_task.AsTask().Result;
}
})
.ContinueWith<Windows.Graphics.Imaging.SoftwareBitmap>(
(task) =>
{
var decoder = task.Result;
var software_bitmap_task = decoder.GetSoftwareBitmapAsync();
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

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

View file

@ -1,14 +1,14 @@
<?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.200512.7\build\Microsoft.Windows.CsWinRT.props" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props')" />
<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.CSharp</RootNamespace>
<AssemblyName>Microsoft.AI.MachineLearning.Tests.CSharp</AssemblyName>
<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>
@ -59,7 +59,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AI.MachineLearning.Interop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll</HintPath>
<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>
@ -73,7 +73,7 @@
<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.200512.7\lib\netstandard2.0\winrt.runtime.dll</HintPath>
<HintPath>packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\lib\netstandard2.0\winrt.runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -102,10 +102,10 @@
<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.200512.7\build\Microsoft.Windows.CsWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets'))" />
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets'))" />
<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.200512.7\build\Microsoft.Windows.CsWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" />
<Import Project="packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200626-0616-f44313c3d\build\netstandard2.0\Microsoft.AI.MachineLearning.targets')" />
<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,14 +1,14 @@
<?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.200512.7\build\Microsoft.Windows.CsWinRT.props" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props')" />
<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.CSharp</RootNamespace>
<AssemblyName>Microsoft.AI.MachineLearning.Tests.CSharp</AssemblyName>
<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>
@ -73,7 +73,7 @@
<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.200512.7\lib\netstandard2.0\winrt.runtime.dll</HintPath>
<HintPath>packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\lib\netstandard2.0\winrt.runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -102,10 +102,10 @@
<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.200512.7\build\Microsoft.Windows.CsWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets'))" />
<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.200512.7\build\Microsoft.Windows.CsWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200512.7\build\Microsoft.Windows.CsWinRT.targets')" />
<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

@ -0,0 +1,31 @@

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

@ -0,0 +1,10 @@
<?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

@ -0,0 +1,10 @@
<?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

@ -0,0 +1,77 @@
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 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AI.MachineLearning" version="1.3.1-dev-20200626-0616-f44313c3d" targetFramework="net472" />
<package id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200512.7" targetFramework="net472" />
<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 +1,6 @@
<?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.200512.7" 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

@ -346,26 +346,34 @@ jobs:
workingDirectory: $(Build.ArtifactStagingDirectory)\merged
- task: PowerShell@2
displayName: 'NuGet Tests: Restore Windows.AI.MachineLearning Nuget Package (C#)'
displayName: 'NuGet Tests: Build Tests (CppWinRT)'
inputs:
targetType: 'inline'
script: |
msbuild /p:Platform=x86 Microsoft.AI.MachineLearning.Tests.vcxproj
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_root_dir = $Env:BUILD_SOURCESDIRECTORY;
$artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY;
$merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged')
$src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.CSharp')
$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 = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.CSharp.csproj.pp')
$csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.CSharp.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
@ -379,23 +387,56 @@ jobs:
nuget restore -PackagesDirectory $packages_dir -Source https://api.nuget.org/v3/index.json -Source $merged_nuget_path $csproj
workingDirectory: $(Build.ArtifactStagingDirectory)\merged
- task: PowerShell@2
displayName: 'NuGet Tests: Build Tests (CppWinRT)'
inputs:
targetType: 'inline'
script: |
msbuild /p:Platform=x86 Microsoft.AI.MachineLearning.Tests.vcxproj
msbuild /p:Platform=x64 Microsoft.AI.MachineLearning.Tests.vcxproj
workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests
- 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)'
inputs:
targetType: 'inline'
script: |
msbuild Microsoft.AI.MachineLearning.Tests.CSharp.csproj /p:Platform=AnyCpu
msbuild Microsoft.AI.MachineLearning.Tests.CSharp.csproj /p:Platform=x64
workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.CSharp
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
- task: PowerShell@2
displayName: 'NuGet Tests: Run Tests'
@ -411,13 +452,19 @@ jobs:
pushd .\Microsoft.AI.MachineLearning.Tests\x64\Debug
.\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
popd
Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (AnyCpu)"
pushd .\Microsoft.AI.MachineLearning.Tests.CSharp\bin\Debug
.\Microsoft.AI.MachineLearning.Tests.CSharp.exe
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.CSharp\bin\x64\Debug
.\Microsoft.AI.MachineLearning.Tests.CSharp.exe
pushd .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2\bin\x64\Debug
.\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.exe
popd
Write-Host "Done!"
workingDirectory: $(Build.SourcesDirectory)\csharp\test

View file

@ -77,14 +77,17 @@ def generate_dependencies(list, package_name, version):
# 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>')
# UAP10.0.16299, This is the earliest release of the OS that supports .NET Standard apps
list.append('<group targetFramework="UAP10.0.16299">')