Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .Net 4.5. #411

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ Thumbs.db
*.dotCover

.vs
*.GhostDoc.xml
*.GhostDoc.xml

# tensorflow native binaries
runtimes/
1.12.0/

# xunit console tools
xunit.runner.console-2.1.0
tools/
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
language: csharp
solution: TensorFlowSharp.sln
script:
- tsh_version=1.4.0-pre1
- tsh_version=1.12.0
- wget "https://www.nuget.org/api/v2/package/TensorFlowSharp/$tsh_version"
- tar xzvf $tsh_version native
- msbuild /t:Restore $TRAVIS_BUILD_DIR/TensorFlowSharp.sln
- tar xzvf $tsh_version runtimes
- dotnet restore $TRAVIS_BUILD_DIR/TensorFlowSharp.sln
- cd $TRAVIS_BUILD_DIR/
- msbuild /p:Configuration=Release TensorFlowSharp.sln
- cp -R $TRAVIS_BUILD_DIR/native/*.dylib $TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests/bin/Release/
- cp -R $TRAVIS_BUILD_DIR/native/*.dylib $TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests.CSharp/bin/Release/
- cd $TRAVIS_BUILD_DIR/packages/xunit.runner.console.2.2.0/tools
- cp "$TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests/obj/Release/FSharp.Core.dll" .
- mono --arch=64 xunit.console.exe "$TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests/bin/Release/TensorFlowSharp.Tests.dll" "$TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests.CSharp/bin/Release/TensorFlowSharp.Tests.CSharp.dll"
- cp $TRAVIS_BUILD_DIR/runtimes/osx/native/*.dylib $TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests/bin/Release/net471/
- cp -R $TRAVIS_BUILD_DIR/runtimes/osx/native/*.dylib $TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests.CSharp/bin/Release/net471/
- wget "https://www.nuget.org/api/v2/package/xunit.runner.console/2.1.0" -O xunit.runner.console-2.1.0
- tar xzvf xunit.runner.console-2.1.0 tools
- cd $TRAVIS_BUILD_DIR/tools
- cp "$TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests/bin/Release/net471/FSharp.Core.dll" .
- mono --arch=64 xunit.console.exe "$TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests/bin/Release/net471/TensorFlowSharp.Tests.dll" "$TRAVIS_BUILD_DIR/tests/TensorFlowSharp.Tests.CSharp/bin/Release/net471/TensorFlowSharp.Tests.CSharp.dll"
mono: "5.10.0"
dotnet: "2.1.4"
os: "osx"
43 changes: 43 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# How to Build and Test

Unfortunately, the process is currently more manual than would be ideal. If you want to build TensorFlowSharp
from source, you first need to get the TensorFlow native binaries. CONTRIBUTING.md contains info about how to
build those from source as well or download pre-built binaries from Google. Alternatively, you can extract the
pre-built binaries from the official TensorFlowSharp nuget package. This is the easiest approach.

To do that, browse to nuget.org, find the latest TensorFlowSharp package and download the `.nupkg` file. Unzip
it (nupkg files are just zip files with a different extension) and copy the `runtimes` directory and all of its
subdirectories to `runtimes` at the root of this repo.

## Building

Once the native libraries have been copied to the `runtimes` directory, you should be able to build the project with
`dotnet build`. This will build for .net4.5, .net4.6 and newer and netstandard2.0. If you specify, `-c Release` as an
option on the build commandline, it will also produce a copy of the nupkg file with all three binary types packed inside
(as well as the native libraries for windows, osx and linux).

## Testing

In order to test on net45 or net471, you will need to download `xunit.console.exe`. Once again, you can browse to
nuget.org and find the `2.1.0` version of the package `xunit.runners.console`. You must use this old version of xunit
beacuse newer versions do not support net45. Download the nupkg file, unzip it, and copy the `tools` directory to
`tools` at the root of this repo.

### Testing for Net45

From the root of the repo run `tools\xunit.console.exe tests\TensorFlowSharp.Tests\bin\debug\net45\TensorFlowSharp.Tests.dll tests\TensorFlowSharp.Tests.CSharp\bin\debug\net45\TensorFlowSharp.Tests.CSharp.dll`

On windows 6 tests fail. Results may be slightly different on other platforms.

### Testing for Net471

From the root of the repo run `tools\xunit.console.exe tests\TensorFlowSharp.Tests\bin\debug\net471\TensorFlowSharp.Tests.dll tests\TensorFlowSharp.Tests.CSharp\bin\debug\net471\TensorFlowSharp.Tests.CSharp.dll`

On windows 6 tests fail. Results may be slightly different on other platforms.

### Testing for NetStandard2.0

From the root of the repo run `dotnet test`.

On Windows 1 test fails in the f# test project, and 6 tests fail in the c# test project. Results may be slightly
different on other platforms.
57 changes: 6 additions & 51 deletions Examples/ExampleCommon/ExampleCommon.csproj
Original file line number Diff line number Diff line change
@@ -1,56 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{116BA176-F67C-4066-8685-C080705BAA16}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ExampleCommon</RootNamespace>
<AssemblyName>ExampleCommon</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ReleaseVersion>0.2</ReleaseVersion>
<TargetFrameworks>net45;net471;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="CatalogUtil.cs" />
<Compile Include="ImageUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\TensorFlowSharp\TensorFlowSharp.csproj">
<Project>{0264c321-34f4-46af-819e-168d1e597232}</Project>
<Name>TensorFlowSharp</Name>
</ProjectReference>
<ProjectReference Include="..\..\TensorFlowSharp\TensorFlowSharp.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

</Project>
36 changes: 0 additions & 36 deletions Examples/ExampleCommon/Properties/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,59 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{069A6736-7711-4805-8660-A267E713BC54}</ProjectGuid>
<TargetFrameworks>net45;net471;netcoreapp2.2</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>ExampleInceptionInference</RootNamespace>
<AssemblyName>ExampleInceptionInference</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<ReleaseVersion>0.2</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Mono.Options">
<HintPath>..\..\packages\Mono.Options.4.4.0.0\lib\net4-client\Mono.Options.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\TensorFlowSharp\TensorFlowSharp.csproj">
<Project>{0264C321-34F4-46AF-819E-168D1E597232}</Project>
<Name>TensorFlowSharp</Name>
</ProjectReference>
<ProjectReference Include="..\ExampleCommon\ExampleCommon.csproj">
<Project>{116BA176-F67C-4066-8685-C080705BAA16}</Project>
<Name>ExampleCommon</Name>
</ProjectReference>
<ProjectReference Include="..\..\TensorFlowSharp\TensorFlowSharp.csproj" />
<ProjectReference Include="..\ExampleCommon\ExampleCommon.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="packages.config" />
<PackageReference Include="Mono.Options" Version="4.4.0" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

</Project>
26 changes: 0 additions & 26 deletions Examples/ExampleInceptionInference/Properties/AssemblyInfo.cs

This file was deleted.

4 changes: 0 additions & 4 deletions Examples/ExampleInceptionInference/packages.config

This file was deleted.

3 changes: 0 additions & 3 deletions Examples/ExampleObjectDetection/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@
<add key="DefaultModelUrl" value="http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017.tar.gz"/>
<add key="DefaultTextsUrl" value="https://raw.githubusercontent.com/tensorflow/models/master/research/object_detection/data/mscoco_label_map.pbtxt"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
Loading