|
1 | 1 | <Project>
|
2 |
| - <Target Name="Initialize" AfterTargets="Publish;Build"> |
3 |
| - <CreateItem Include="$(MSBuildThisFileDirectory)\..\"> |
4 |
| - <Output ItemName="MSBuildThisFileDirectoryParentDirectory" TaskParameter="Include"/> |
5 |
| - </CreateItem> |
6 | 2 |
|
7 |
| - <CreateProperty Value="%(MSBuildThisFileDirectoryParentDirectory.Fullpath)"> |
8 |
| - <Output PropertyName="NugetRoot" TaskParameter="Value"/> |
9 |
| - </CreateProperty> |
| 3 | + <PropertyGroup> |
| 4 | + <_PythonWorkerToolsDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../tools'))</_PythonWorkerToolsDir> |
| 5 | + </PropertyGroup> |
10 | 6 |
|
| 7 | + <ItemGroup Condition="'$(RuntimeIdentifier)' != ''"> |
| 8 | + <_PythonSupportedRuntime Include="win-x86" WorkerPath="WINDOWS/X86" /> |
| 9 | + <_PythonSupportedRuntime Include="win-x64" WorkerPath="WINDOWS/X64" /> |
| 10 | + <_PythonSupportedRuntime Include="linux-x64" WorkerPath="LINUX/X64" /> |
| 11 | + <_PythonSupportedRuntime Include="osx-x64" WorkerPath="OSX/X64" /> |
| 12 | + <_PythonSupportedRuntime Include="osx-arm64" WorkerPath="OSX/Arm64" /> |
| 13 | + </ItemGroup> |
| 14 | + |
| 15 | + <Target Name="_GetFunctionsPythonWorkerFiles" BeforeTargets="AssignTargetPaths" DependsOnTargets="_GetFunctionsPythonWorkerFilesNoRuntime;_GetFunctionsPythonWorkerFilesForRuntime"> |
11 | 16 | <ItemGroup>
|
12 |
| - <SourceFiles Include="$(NugetRoot)tools\**\*.*"/> |
| 17 | + <None Include="@(_PythonWorkerFiles)" TargetPath="workers/python/%(RecursiveDir)%(Filename)%(Extension)" /> |
13 | 18 | </ItemGroup>
|
14 | 19 | </Target>
|
15 | 20 |
|
16 |
| - <Target Name="CopyOnPublish" DependsOnTargets="Initialize" AfterTargets="Publish"> |
17 |
| - <Copy SourceFiles="@(SourceFiles)" |
18 |
| - DestinationFiles="@(SourceFiles->'$(PublishDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" /> |
| 21 | + <!-- When no runtime is specified, copy all runtimes. --> |
| 22 | + <Target Name="_GetFunctionsPythonWorkerFilesNoRuntime" Condition="'$(RuntimeIdentifier)' == ''"> |
| 23 | + <ItemGroup> |
| 24 | + <_PythonWorkerFiles Include="$(_PythonWorkerToolsDir)/**" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> |
| 25 | + </ItemGroup> |
19 | 26 | </Target>
|
20 | 27 |
|
21 |
| - <Target Name="CopyOnBuild" DependsOnTargets="Initialize" AfterTargets="Build"> |
22 |
| - <Copy SourceFiles="@(SourceFiles)" |
23 |
| - DestinationFiles="@(SourceFiles->'$(OutDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" /> |
| 28 | + <!-- When a runtime is specified, copy only that runtimes files. --> |
| 29 | + <Target Name="_GetFunctionsPythonWorkerFilesForRuntime" Condition="'$(RuntimeIdentifier)' != ''"> |
| 30 | + <PropertyGroup> |
| 31 | + <_PythonWorkersRuntimeFolder>@(_PythonSupportedRuntime->WithMetadataValue('Identity', '$(RuntimeIdentifier)')->Metadata('WorkerPath'))</_PythonWorkersRuntimeFolder> |
| 32 | + </PropertyGroup> |
| 33 | + |
| 34 | + <ItemGroup> |
| 35 | + <_PythonWorkerFiles Include="$(_PythonWorkerToolsDir)/*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> |
| 36 | + <_PythonWorkerFiles Include="$(_PythonWorkerToolsDir)/**/$(_PythonWorkersRuntimeFolder)/**" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> |
| 37 | + </ItemGroup> |
| 38 | + |
| 39 | + <!-- Error out if runtime is not supported. --> |
| 40 | + <Error Condition="'$(_PythonWorkersRuntimeFolder)' == ''" Text="Runtime '$(RuntimeIdentifier)' is not supported by the Python worker. Supported runtimes are @(_PythonSupportedRuntime)." /> |
24 | 41 | </Target>
|
| 42 | + |
25 | 43 | </Project>
|
0 commit comments