You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

SciSharp.TensorFlow.Redist-Linux-GPU.nupkgproj 8.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <Project Sdk="Microsoft.NET.Sdk">
  2. <PropertyGroup>
  3. <ProjDir>$(MSBuildThisFileDirectory)</ProjDir>
  4. <BinDir>$(ProjDir)bin\</BinDir>
  5. <ObjDir>$(ProjDir)obj\</ObjDir>
  6. <TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
  7. <TargetFramework>netstandard2.0</TargetFramework>
  8. <TensorFlowVersion>1.14.0</TensorFlowVersion>
  9. <TensorFlowMajorVersion>1</TensorFlowMajorVersion>
  10. <PackageAssetsPath>$(BinDir)packages\</PackageAssetsPath>
  11. <PackageId>$(MSBuildProjectName)</PackageId>
  12. <PackageVersion>$(TensorFlowVersion)</PackageVersion>
  13. <NoBuild>true</NoBuild>
  14. <IncludeBuildOutput>false</IncludeBuildOutput>
  15. <NuspecFile>Redist-Windows-GPU.nuspec</NuspecFile>
  16. <NuspecProperties>packageId=$(PackageId);version=$(PackageVersion)</NuspecProperties>
  17. <NuspecBasePath>$(ProjDir)</NuspecBasePath>
  18. <GenerateNuspecDependsOn>CopyFilesFromArchive</GenerateNuspecDependsOn>
  19. <PackageRid Condition="'$(OS)' == 'Windows_NT'">win</PackageRid>
  20. <PackageRid Condition="'$(OS)' != 'Windows_NT'">linux</PackageRid>
  21. <PackageRid Condition="$([MSBuild]::IsOSPlatform('osx'))">osx</PackageRid>
  22. <PackageRid>$(PackageRid)-$(TargetArchitecture)</PackageRid>
  23. </PropertyGroup>
  24. <PropertyGroup>
  25. <IncludeMLNetNotices>false</IncludeMLNetNotices>
  26. </PropertyGroup>
  27. <ItemGroup>
  28. <TensorFlowConfig Condition="'$(OS)' != 'Windows_NT'"
  29. Include="linux"
  30. FileExtension=".tar.gz"
  31. FilesFromArchive="lib\libtensorflow.so;
  32. lib\libtensorflow_framework.so.$(TensorFlowMajorVersion);
  33. include\tensorflow\c\LICENSE"
  34. Runtime="linux-x64" />
  35. <AdditionalDownloadFile Include="https://raw.githubusercontent.com/tensorflow/tensorflow/master/LICENSE"
  36. DownloadFile="$(BinDir)LICENSE" />
  37. </ItemGroup>
  38. <Target Name="PrepareArchives">
  39. <ItemGroup>
  40. <!-- although we could extract all archives on all machines, mac requires a fixup which can only be run on mac
  41. so we split these per-rid and join during the official build packaging. -->
  42. <TensorFlowArchive
  43. Include="@(TensorFlowConfig->'https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-%(Identity)-x86_64-$(TensorFlowVersion)%(FileExtension)')" />
  44. <!-- set up metdata used by all targets -->
  45. <TensorFlowArchive DownloadFile="$(BinDir)%(FileName)%(Extension)"
  46. DownloadShaFile="$(BinDir)%(FileName)%(Extension).sha"
  47. ExtractDirectory="$(BinDir)%(FileName)"
  48. ExtractSemaphore="$(BinDir)%(FileName)\.extracted"
  49. LocalShaFile="$(BinDir)\%(FileName)%(Extension).sha"/>
  50. </ItemGroup>
  51. <Message Importance="high" Text="%(TensorFlowConfig.Runtime)"/>
  52. </Target>
  53. <Target Name="DownloadArchives"
  54. DependsOnTargets="PrepareArchives"
  55. Inputs="$(MSBuildProjectFile)"
  56. Outputs="@(TensorFlowArchive->'%(DownloadFile)');@(AdditionalDownloadFile->'%(DownloadFile)')">
  57. <MakeDir Directories="$(BinDir)" />
  58. <ItemGroup>
  59. <_downloadFiles Include="@(TensorFlowArchive);@(AdditionalDownloadFile)" Url="%(Identity)" DestinationFile="%(DownloadFile)" />
  60. </ItemGroup>
  61. <Message Importance="High" Text="Downloading '%(_downloadFiles.Identity)' to '$(BinDir)'." />
  62. <DownloadFile SourceUrl="%(_downloadFiles.Identity)" DestinationFolder="$(BinDir)">
  63. <Output TaskParameter="DownloadedFile" ItemName="Content" />
  64. </DownloadFile>
  65. </Target>
  66. <Target Name="ValidateAndExtractArchives"
  67. DependsOnTargets="DownloadArchives"
  68. Inputs="@(TensorFlowArchive->'%(DownloadFile)')"
  69. Outputs="@(TensorFlowArchive->'%(ExtractSemaphore)')">
  70. <GetFileHash Files="@(TensorFlowArchive->'%(DownloadFile)')" Algorithm="SHA512">
  71. <Output
  72. TaskParameter="Items"
  73. ItemName="FilesWithHashes" />
  74. </GetFileHash>
  75. <WriteLinesToFile File="%(FilesWithHashes.Identity).sha" Lines="%(FilesWithHashes.FileHash)" Overwrite="true"/>
  76. <!-- If specified we'll update the checked in SHAs with the downloaded ones. -->
  77. <Copy Condition="'$(UpdateSHA)' == 'true'"
  78. SourceFiles="@(TensorFlowArchive->'%(DownloadShaFile)')"
  79. DestinationFiles="@(TensorFlowArchive->'%(LocalShaFile)')" />
  80. <ItemGroup>
  81. <TensorFlowArchive>
  82. <DownloadSha>@(FilesWithHashes->'%(FileHash)')</DownloadSha>
  83. <LocalSha>$([System.IO.File]::ReadAllText('%(LocalShaFile)').Replace("%0A", "").Replace("%0D", ""))</LocalSha>
  84. </TensorFlowArchive>
  85. </ItemGroup>
  86. <Error Condition="!Exists('%(TensorFlowArchive.LocalShaFile)')" Text="SHA file '%(TensorFlowArchive.LocalShaFile)' does not exist. Build with /p:UpdateSHA=true to save it." />
  87. <Message Importance="High" Text="@TensorFlowArchive->'%(TensorFlowArchive.DownloadFile) - %(TensorFlowArchive.LocalSha) - %(TensorFlowArchive.DownloadSha)"/>
  88. <!-- Validate that the downloaded SHAs match the expected checked in SHAs -->
  89. <Error Condition="'%(TensorFlowArchive.LocalSha)' != '%(TensorFlowArchive.DownloadSha)'" Text="Downloaded file '%(TensorFlowArchive.DownloadFile)' has unexpected SHA.%0A expected: %(TensorFlowArchive.LocalSha)%0A --actual: %(TensorFlowArchive.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." />
  90. <!-- The archives are valid, lets extract them, ensuring an empty directory -->
  91. <RemoveDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
  92. <MakeDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
  93. <Message Importance="High" Text="Decompressing '%(TensorFlowArchive.DownloadFile)' to '%(TensorFlowArchive.ExtractDirectory)'." />
  94. <Unzip Condition="'%(TensorFlowArchive.FileExtension)' == '.zip'"
  95. SourceFiles="%(TensorFlowArchive.DownloadFile)"
  96. DestinationFolder="%(TensorFlowArchive.ExtractDirectory)" />
  97. <Exec Condition="'$(OS)' != 'Windows_NT' AND '%(TensorFlowArchive.FileExtension)' == '.tar.gz'"
  98. WorkingDirectory="$(MSBuildThisFileDirectory)"
  99. Command="tar -xzm --hard-dereference -f %(TensorFlowArchive.DownloadFile) -C %(TensorFlowArchive.ExtractDirectory)" />
  100. <Exec Condition="'$(OS)' != 'Windows_NT'"
  101. Command="chmod -R +w %(TensorFlowArchive.ExtractDirectory)" />
  102. <Touch Files="@(TensorFlowArchive->'%(ExtractSemaphore)')" AlwaysCreate="true" />
  103. </Target>
  104. <!-- Select the files we want to copy out of each archive. -->
  105. <Target Name="GetFilesFromArchive"
  106. DependsOnTargets="ValidateAndExtractArchives" >
  107. <ItemGroup>
  108. <!-- batch rather than transform so that we can split FilesFromArchive metadata -->
  109. <_fileFromArchive Include="%(TensorFlowArchive.FilesFromArchive)" ExtractDirectory="%(TensorFlowArchive.ExtractDirectory)" Runtime="%(TensorFlowArchive.Runtime)" />
  110. <_fileFromArchive DestinationFile="%(FileName)%(Extension)"/>
  111. <_fileFromArchive PackagePath="runtimes\%(_fileFromArchive.Runtime)\native\%(_fileFromArchive.DestinationFile)" />
  112. <!-- LICENSE from the package is actually THIRD_PARTY_NOTICES-->
  113. <_fileFromArchive Condition="'%(DestinationFile)' == 'LICENSE'" PackagePath="THIRD_PARTY_NOTICES.txt" Runtime="" />
  114. <!-- copy to packaging location -->
  115. <FilesFromArchive Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
  116. TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\%(PackagePath)" />
  117. <!-- include LICENSE that was downloaded from GitHub -->
  118. <FilesFromArchive Include="$(BinDir)\LICENSE"
  119. TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\LICENSE.txt" />
  120. <!-- copy to NativeAssets location, only for current RID, so that they may be used by tests -->
  121. <!--<FilesFromArchive Condition="'$(PackageRID)' == '%(_fileFromArchive.Runtime)'"
  122. Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
  123. TargetPath="$(NativeAssetsBuiltPath)\%(_fileFromArchive.DestinationFile)" />-->
  124. </ItemGroup>
  125. </Target>
  126. <Target Name="CopyFilesFromArchive"
  127. DependsOnTargets="GetFilesFromArchive">
  128. <Message Importance="High" Text="@(FilesFromArchive) -> %(FilesFromArchive.TargetPath)" />
  129. <Copy SourceFiles="@(FilesFromArchive)"
  130. DestinationFiles="@(FilesFromArchive->'%(TargetPath)')" />
  131. </Target>
  132. <Target Name="Clean">
  133. <Message Importance="High" Text="Deleting $(BinDir);$(ObjDir)" />
  134. <RemoveDir Directories="$(BinDir);$(ObjDir)" />
  135. </Target>
  136. </Project>