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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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-CPU.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. <WriteLinesToFile File="%(FilesWithHashes.Identity).sha" Lines="%(FilesWithHashes.FileHash)" Overwrite="true"/>
  87. <!-- If specified we'll update the checked in SHAs with the downloaded ones. -->
  88. <Copy Condition="'$(UpdateSHA)' == 'true'"
  89. SourceFiles="@(TensorFlowArchive->'%(DownloadShaFile)')"
  90. DestinationFiles="@(TensorFlowArchive->'%(LocalShaFile)')" />
  91. <ItemGroup>
  92. <TensorFlowArchive>
  93. <DownloadSha>@(FilesWithHashes->'%(FileHash)')</DownloadSha>
  94. <LocalSha>$([System.IO.File]::ReadAllText('%(LocalShaFile)').Replace("%0A", "").Replace("%0D", ""))</LocalSha>
  95. </TensorFlowArchive>
  96. </ItemGroup>
  97. <Error Condition="!Exists('%(TensorFlowArchive.LocalShaFile)')" Text="SHA file '%(TensorFlowArchive.LocalShaFile)' does not exist. Build with /p:UpdateSHA=true to save it." />
  98. <Message Importance="High" Text="@TensorFlowArchive->'%(TensorFlowArchive.DownloadFile) - %(TensorFlowArchive.LocalSha) - %(TensorFlowArchive.DownloadSha)"/>
  99. <!-- Validate that the downloaded SHAs match the expected checked in SHAs -->
  100. <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." />
  101. <!-- The archives are valid, lets extract them, ensuring an empty directory -->
  102. <RemoveDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
  103. <MakeDir Directories="@(TensorFlowArchive->'%(ExtractDirectory)')" />
  104. <Message Importance="High" Text="Decompressing '%(TensorFlowArchive.DownloadFile)' to '%(TensorFlowArchive.ExtractDirectory)'." />
  105. <Unzip Condition="'%(TensorFlowArchive.FileExtension)' == '.zip'"
  106. SourceFiles="%(TensorFlowArchive.DownloadFile)"
  107. DestinationFolder="%(TensorFlowArchive.ExtractDirectory)" />
  108. <Exec Condition="'$(OS)' != 'Windows_NT' AND '%(TensorFlowArchive.FileExtension)' == '.tar.gz'"
  109. WorkingDirectory="$(MSBuildThisFileDirectory)"
  110. Command="tar -xzm --hard-dereference -f %(TensorFlowArchive.DownloadFile) -C %(TensorFlowArchive.ExtractDirectory)" />
  111. <Exec Condition="'$(OS)' != 'Windows_NT'"
  112. Command="chmod -R +w %(TensorFlowArchive.ExtractDirectory)" />
  113. <Touch Files="@(TensorFlowArchive->'%(ExtractSemaphore)')" AlwaysCreate="true" />
  114. </Target>
  115. <!-- Select the files we want to copy out of each archive. -->
  116. <Target Name="GetFilesFromArchive"
  117. DependsOnTargets="ValidateAndExtractArchives" >
  118. <ItemGroup>
  119. <!-- batch rather than transform so that we can split FilesFromArchive metadata -->
  120. <_fileFromArchive Include="%(TensorFlowArchive.FilesFromArchive)" ExtractDirectory="%(TensorFlowArchive.ExtractDirectory)" Runtime="%(TensorFlowArchive.Runtime)" />
  121. <_fileFromArchive DestinationFile="%(FileName)%(Extension)"/>
  122. <_fileFromArchive PackagePath="runtimes\%(_fileFromArchive.Runtime)\native\%(_fileFromArchive.DestinationFile)" />
  123. <!-- LICENSE from the package is actually THIRD_PARTY_NOTICES-->
  124. <_fileFromArchive Condition="'%(DestinationFile)' == 'LICENSE'" PackagePath="THIRD_PARTY_NOTICES.txt" Runtime="" />
  125. <!-- copy to packaging location -->
  126. <FilesFromArchive Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
  127. TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\%(PackagePath)" />
  128. <!-- include LICENSE that was downloaded from GitHub -->
  129. <FilesFromArchive Include="$(BinDir)\LICENSE"
  130. TargetPath="$(PackageAssetsPath)$(MSBuildProjectName)\LICENSE.txt" />
  131. <!-- copy to NativeAssets location, only for current RID, so that they may be used by tests -->
  132. <!--<FilesFromArchive Condition="'$(PackageRID)' == '%(_fileFromArchive.Runtime)'"
  133. Include="@(_fileFromArchive->'%(ExtractDirectory)\%(Identity)')"
  134. TargetPath="$(NativeAssetsBuiltPath)\%(_fileFromArchive.DestinationFile)" />-->
  135. </ItemGroup>
  136. </Target>
  137. <Target Name="CopyFilesFromArchive"
  138. DependsOnTargets="GetFilesFromArchive">
  139. <Message Importance="High" Text="@(FilesFromArchive) -> %(FilesFromArchive.TargetPath)" />
  140. <Copy SourceFiles="@(FilesFromArchive)"
  141. DestinationFiles="@(FilesFromArchive->'%(TargetPath)')" />
  142. </Target>
  143. <Target Name="Clean">
  144. <Message Importance="High" Text="Deleting $(BinDir);$(ObjDir)" />
  145. <RemoveDir Directories="$(BinDir);$(ObjDir)" />
  146. </Target>
  147. </Project>