-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Remove custom targets, use 'None' item group (#1472)
* Remove custom targets, use 'None' item group * Add runtime specific copy logic * Add underscore to target name --------- Co-authored-by: wangbill <[email protected]> Co-authored-by: hallvictoria <[email protected]> Co-authored-by: Gavin Aguiar <[email protected]>
- Loading branch information
1 parent
bbb6624
commit 43e5a72
Showing
1 changed file
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,43 @@ | ||
<Project> | ||
<Target Name="Initialize" AfterTargets="Publish;Build"> | ||
<CreateItem Include="$(MSBuildThisFileDirectory)\..\"> | ||
<Output ItemName="MSBuildThisFileDirectoryParentDirectory" TaskParameter="Include"/> | ||
</CreateItem> | ||
|
||
<CreateProperty Value="%(MSBuildThisFileDirectoryParentDirectory.Fullpath)"> | ||
<Output PropertyName="NugetRoot" TaskParameter="Value"/> | ||
</CreateProperty> | ||
<PropertyGroup> | ||
<_PythonWorkerToolsDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../tools'))</_PythonWorkerToolsDir> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(RuntimeIdentifier)' != ''"> | ||
<_PythonSupportedRuntime Include="win-x86" WorkerPath="WINDOWS/X86" /> | ||
<_PythonSupportedRuntime Include="win-x64" WorkerPath="WINDOWS/X64" /> | ||
<_PythonSupportedRuntime Include="linux-x64" WorkerPath="LINUX/X64" /> | ||
<_PythonSupportedRuntime Include="osx-x64" WorkerPath="OSX/X64" /> | ||
<_PythonSupportedRuntime Include="osx-arm64" WorkerPath="OSX/Arm64" /> | ||
</ItemGroup> | ||
|
||
<Target Name="_GetFunctionsPythonWorkerFiles" BeforeTargets="AssignTargetPaths" DependsOnTargets="_GetFunctionsPythonWorkerFilesNoRuntime;_GetFunctionsPythonWorkerFilesForRuntime"> | ||
<ItemGroup> | ||
<SourceFiles Include="$(NugetRoot)tools\**\*.*"/> | ||
<None Include="@(_PythonWorkerFiles)" TargetPath="workers/python/%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="CopyOnPublish" DependsOnTargets="Initialize" AfterTargets="Publish"> | ||
<Copy SourceFiles="@(SourceFiles)" | ||
DestinationFiles="@(SourceFiles->'$(PublishDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" /> | ||
<!-- When no runtime is specified, copy all runtimes. --> | ||
<Target Name="_GetFunctionsPythonWorkerFilesNoRuntime" Condition="'$(RuntimeIdentifier)' == ''"> | ||
<ItemGroup> | ||
<_PythonWorkerFiles Include="$(_PythonWorkerToolsDir)/**" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="CopyOnBuild" DependsOnTargets="Initialize" AfterTargets="Build"> | ||
<Copy SourceFiles="@(SourceFiles)" | ||
DestinationFiles="@(SourceFiles->'$(OutDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" /> | ||
<!-- When a runtime is specified, copy only that runtimes files. --> | ||
<Target Name="_GetFunctionsPythonWorkerFilesForRuntime" Condition="'$(RuntimeIdentifier)' != ''"> | ||
<PropertyGroup> | ||
<_PythonWorkersRuntimeFolder>@(_PythonSupportedRuntime->WithMetadataValue('Identity', '$(RuntimeIdentifier)')->Metadata('WorkerPath'))</_PythonWorkersRuntimeFolder> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<_PythonWorkerFiles Include="$(_PythonWorkerToolsDir)/*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> | ||
<_PythonWorkerFiles Include="$(_PythonWorkerToolsDir)/**/$(_PythonWorkersRuntimeFolder)/**" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> | ||
</ItemGroup> | ||
|
||
<!-- Error out if runtime is not supported. --> | ||
<Error Condition="'$(_PythonWorkersRuntimeFolder)' == ''" Text="Runtime '$(RuntimeIdentifier)' is not supported by the Python worker. Supported runtimes are @(_PythonSupportedRuntime)." /> | ||
</Target> | ||
|
||
</Project> |