Skip to content
Merged
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
24 changes: 24 additions & 0 deletions src/SciSharp.TensorFlow.Redist/CommonPackage.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--
NuGet packages.config doesn't support native assemblies automatically,
so copy the native assemblies to the output directory.
-->
<ItemGroup Condition="Exists('packages.config') OR
Exists('$(MSBuildProjectName).packages.config') OR
Exists('packages.$(MSBuildProjectName).config')">
<Content Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win-x64\native\*.dll"
Condition="'$(PlatformTarget)' == 'x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Link>%(Filename)%(Extension)</Link>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win-x86\native\*.dll"
Condition="'$(PlatformTarget)' == 'x86'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Link>%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>

</Project>
188 changes: 188 additions & 0 deletions src/SciSharp.TensorFlow.Redist/SciSharp.TensorFlow.Redist.nupkgproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ProjDir>$(MSBuildThisFileDirectory)</ProjDir>
<BinDir>$(ProjDir)bin\</BinDir>
<ObjDir>$(ProjDir)obj\</ObjDir>

<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
<TargetFramework>netstandard2.0</TargetFramework>
<TensorFlowVersion>1.14.0</TensorFlowVersion>
<TensorFlowMajorVersion>1</TensorFlowMajorVersion>

<PackageAssetsPath>$(BinDir)packages\</PackageAssetsPath>
<PackageId>$(MSBuildProjectName)</PackageId>
<PackageVersion>$(TensorFlowVersion)</PackageVersion>

<NoBuild>true</NoBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>

<NuspecFile>Redist.nuspec</NuspecFile>
<NuspecProperties>packageId=$(PackageId);version=$(PackageVersion)</NuspecProperties>
<NuspecBasePath>$(ProjDir)</NuspecBasePath>

<GenerateNuspecDependsOn>CopyFilesFromArchive</GenerateNuspecDependsOn>

<PackageRid Condition="'$(OS)' == 'Windows_NT'">win</PackageRid>
<PackageRid Condition="'$(OS)' != 'Windows_NT'">linux</PackageRid>
<PackageRid Condition="$([MSBuild]::IsOSPlatform('osx'))">osx</PackageRid>
<PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>

</PropertyGroup>

<PropertyGroup>
<IncludeMLNetNotices>false</IncludeMLNetNotices>
</PropertyGroup>

<ItemGroup>
<TensorFlowConfig Include="windows"
FileExtension=".zip"
FilesFromArchive="lib\tensorflow.dll;
include\tensorflow\c\LICENSE"
Runtime="win-x64"/>

<TensorFlowConfig Condition="'$(OS)' != 'Windows_NT'"
Include="linux"
FileExtension=".tar.gz"
FilesFromArchive="lib\libtensorflow.so;
lib\libtensorflow_framework.so.$(TensorFlowMajorVersion);
include\tensorflow\c\LICENSE"
Runtime="linux-x64" />

<TensorFlowConfig Condition="'$(OS)' != 'Windows_NT'"
Include="darwin" FileExtension=".tar.gz"
FilesFromArchive="lib\libtensorflow.dylib;
lib\libtensorflow_framework.$(TensorFlowMajorVersion).dylib;
include\tensorflow\c\LICENSE"
Runtime="osx-x64" />

<AdditionalDownloadFile Include="https://raw.githubusercontent.com/tensorflow/tensorflow/master/LICENSE"
DownloadFile="$(BinDir)LICENSE" />
</ItemGroup>

<Target Name="PrepareArchives">
<ItemGroup>
<!-- although we could extract all archives on all machines, mac requires a fixup which can only be run on mac
so we split these per-rid and join during the official build packaging. -->
<TensorFlowArchive
Include="@(TensorFlowConfig->'https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-%(Identity)-x86_64-$(TensorFlowVersion)%(FileExtension)')" />
<!-- set up metdata used by all targets -->
<TensorFlowArchive DownloadFile="$(BinDir)%(FileName)%(Extension)"
DownloadShaFile="$(BinDir)%(FileName)%(Extension).sha"
ExtractDirectory="$(BinDir)%(FileName)"
ExtractSemaphore="$(BinDir)%(FileName)\.extracted"
LocalShaFile="$(MSBuildProjectDirectory)\%(FileName)%(Extension).sha"/>
</ItemGroup>
<Message Importance="high" Text="%(TensorFlowConfig.Runtime)"/>
</Target>

<Target Name="DownloadArchives"
DependsOnTargets="PrepareArchives"
Inputs="$(MSBuildProjectFile)"
Outputs="@(TensorFlowArchive->'%(DownloadFile)');@(AdditionalDownloadFile->'%(DownloadFile)')">
<MakeDir Directories="$(BinDir)" />
<ItemGroup>
<_downloadFiles Include="@(TensorFlowArchive);@(AdditionalDownloadFile)" Url="%(Identity)" DestinationFile="%(DownloadFile)" />
</ItemGroup>
<Message Importance="High" Text="Downloading '%(_downloadFiles.Identity)' to '$(BinDir)'." />
<DownloadFile SourceUrl="%(_downloadFiles.Identity)" DestinationFolder="$(BinDir)">
<Output TaskParameter="DownloadedFile" ItemName="Content" />
</DownloadFile>
</Target>


<Target Name="ValidateAndExtractArchives"
DependsOnTargets="DownloadArchives"
Inputs="@(TensorFlowArchive->'%(DownloadFile)')"
Outputs="@(TensorFlowArchive->'%(ExtractSemaphore)')">

<GetFileHash Files="@(TensorFlowArchive->'%(DownloadFile)')" Algorithm="SHA512">
<Output
TaskParameter="Items"
ItemName="FilesWithHashes" />
</GetFileHash>

<Message Importance="High"
Text="%(FilesWithHashes.Identity): %(FilesWithHashes.FileHash)" />

<ItemGroup>
<TensorFlowArchive>
<DownloadSha>@(FilesWithHashes->'%(FileHash)')</DownloadSha>
<LocalSha>$([System.IO.File]::ReadAllText('%(LocalShaFile)'))</LocalSha>
</TensorFlowArchive>
</ItemGroup>

<!-- If specified we'll update the checked in SHAs with the downloaded ones. -->
<!--<WriteLinesToFile Condition="'$(UpdateSHA)' == 'true'"
File="@(TensorFlowArchive->'%(LocalShaFile)')"
Lines="@(TensorFlowArchive->'%(LocalShaFile)')" />-->

<Error Condition="!Exists('%(TensorFlowArchive.LocalShaFile)')" Text="SHA file '%(TensorFlowArchive.LocalShaFile)' does not exist. Build with /p:UpdateSHA=true to save it." />

<Message Importance="High" Text="@TensorFlowArchive->'%(TensorFlowArchive.DownloadFile) - %(TensorFlowArchive.LocalSha) - %(TensorFlowArchive.DownloadSha)"/>

<!-- Validate that the downloaded SHAs match the expected checked in SHAs -->
<Error Condition="'%(TensorFlowArchive.LocalSha)' != '%(TensorFlowArchive.DownloadSha)'" Text="Downloaded file '%(TensorFlowArchive.DownloadFile)' has unexpected SHA.%0A expected: %(_downloadedTensorFlowArchive.LocalSha)%0A actual: %(_downloadedTensorFlowArchive.DownloadSha)%0ABuild with /p:UpdateSHA=true if you intentionally changed the URL and wish to update the SHAs, otherwise this could indicate an incomplete download or intercerpted URL and should be examined." />


<!-- The archives are valid, lets extract them, ensuring an empty directory -->
<RemoveDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
<MakeDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />

<Message Importance="High" Text="Decompressing '%(TensorFlowArchive.DownloadFile)' to '%(TensorFlowArchive.ExtractDirectory)'." />

<Unzip Condition="'%(TensorFlowArchive.FileExtension)' == '.zip'"
SourceFiles="%(TensorFlowArchive.DownloadFile)"
DestinationFolder="%(TensorFlowArchive.ExtractDirectory)" />

<Exec Condition="'$(OS)' != 'Windows_NT' AND '%(TensorFlowArchive.FileExtension)' == '.tar.gz'"
WorkingDirectory="$(MSBuildThisFileDirectory)"
Command="tar -xzm --hard-dereference -f %(TensorFlowArchive.DownloadFile) -C %(TensorFlowArchive.ExtractDirectory)" />

<Exec Condition="'$(OS)' != 'Windows_NT'"
Command="chmod -R +w %(TensorFlowArchive.ExtractDirectory)" />

<Touch Files="@(TensorFlowArchive->'%(ExtractSemaphore)')" AlwaysCreate="true" />
</Target>

<!-- Select the files we want to copy out of each archive. -->
<Target Name="GetFilesFromArchive"
DependsOnTargets="ValidateAndExtractArchives" >
<ItemGroup>
<!-- batch rather than transform so that we can split FilesFromArchive metadata -->
<_fileFromArchive Include="%(TensorFlowArchive.FilesFromArchive)" ExtractDirectory="%(TensorFlowArchive.ExtractDirectory)" Runtime="%(TensorFlowArchive.Runtime)" />
<_fileFromArchive DestinationFile="%(FileName)%(Extension)"/>
<_fileFromArchive PackagePath="runtimes\%(_fileFromArchive.Runtime)\native\%(_fileFromArchive.DestinationFile)" />

<!-- LICENSE from the package is actually THIRD_PARTY_NOTICES-->
<_fileFromArchive Condition="'%(DestinationFile)' == 'LICENSE'" PackagePath="THIRD_PARTY_NOTICES.txt" Runtime="" />

<!-- copy to packaging location -->
<FilesFromArchive Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\%(PackagePath)" />
<!-- include LICENSE that was downloaded from GitHub -->
<FilesFromArchive Include="$(BinDir)\LICENSE"
TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\LICENSE.txt" />

<!-- copy to NativeAssets location, only for current RID, so that they may be used by tests -->
<!--<FilesFromArchive Condition="'$(PackageRID)' == '%(_fileFromArchive.Runtime)'"
Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
TargetPath="$(NativeAssetsBuiltPath)\%(_fileFromArchive.DestinationFile)" />-->
</ItemGroup>
</Target>

<Target Name="CopyFilesFromArchive"
DependsOnTargets="GetFilesFromArchive">

<Message Importance="High" Text="@(FilesFromArchive) -> %(FilesFromArchive.TargetPath)" />
<Copy SourceFiles="@(FilesFromArchive)"
DestinationFiles="@(FilesFromArchive->'%(TargetPath)')" />

</Target>

<Target Name="Clean">
<Message Importance="High" Text="Deleting $(BinDir);$(ObjDir)" />
<RemoveDir Directories="$(BinDir);$(ObjDir)" />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7002EF701BD23C5EF5FF94192E935F0DDF960A21BE2531CEE158586830C00E0BA889900F7F6E8AB568BEE0ACF1F5A6A246BB43D11C4109E9DC782B46377D8142
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
E3F6D0309117E9E45780ECF8BC4D0268B3FC9F12E3E38FFE58496789330A4ACD2DC8FF721F3B8900357F6155F8A54000E45B99495F823486B558E8B42532392D
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
59A2B80B441439B851202358CE4A65BA0DDDB319A8A29E87B135DCD9954BC5B0628F2C0C8E72D6942EA3CDCE172805C2BD5421815B3D0210B62BC0936DC59A08
26 changes: 26 additions & 0 deletions src/SciSharp.TensorFlow.Redist/redist.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>$packageId$</id>
<version>$version$</version>
<authors>The TensorFlow Authors</authors>
<owners>The TensorFlow Authors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">LICENSE.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<projectUrl>https://www.tensorflow.org/</projectUrl>
<description>$packageId$ contains the TensorFlow C library version $version$ redistributed as a NuGet package.</description>
<releaseNotes>https://github.com/tensorflow/tensorflow/releases/tag/v$version$</releaseNotes>
<copyright>Copyright 2019 The TensorFlow Authors. All rights reserved.</copyright>
<tags>TensorFlow</tags>
<dependencies>
<group targetFramework=".NETStandard2.0" />
</dependencies>
</metadata>
<files>
<file src="CommonPackage.props" target="build\netstandard2.0\$packageId$.props" />
<file src="bin\packages\$packageId$\LICENSE.txt" target="LICENSE.txt" />
<file src="bin\packages\$packageId$\THIRD_PARTY_NOTICES.txt" target="THIRD_PARTY_NOTICES.txt" />
<file src="bin\packages\$packageId$\runtimes\**\*" target="runtimes" />
</files>
</package>