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.nupkgproj 9.6 kB

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