-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
64 lines (55 loc) · 2.39 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<Project>
<PropertyGroup>
<BeforePack>_PackToolset</BeforePack>
</PropertyGroup>
<PropertyGroup>
<_ArchiveBase>zig-$(ZigArchiveName)-$(Version)</_ArchiveBase>
<_ArchiveName>$(_ArchiveBase).$(ZigArchiveType)</_ArchiveName>
<_ArchivePath>$(OutputPath)$(_ArchiveName)</_ArchivePath>
<_ArchiveDestination>$(OutputPath)$(_ArchiveBase)/</_ArchiveDestination>
</PropertyGroup>
<ItemGroup>
<None Include="build/**"
Pack="true"
PackagePath="%(Identity)" />
</ItemGroup>
<ItemGroup>
<Zig Include="$(_ArchiveDestination)**" />
</ItemGroup>
<!--
TODO: We currently assume that the tar program can extract XZ archives. This
is not the case for the tar that ships with Windows. So, this target only
really works on Unix systems or in environments that have a proper tar (e.g.
Git Bash).
-->
<Target Name="_RestoreArchive"
AfterTargets="_GenerateRestoreProjectPathWalk">
<DownloadFile SourceUrl="https://ziglang.org/download/$(Version)/$(_ArchiveName)"
DestinationFolder="$(OutputPath)"
Condition="!Exists('$(_ArchivePath)')" />
<MakeDir Directories="$(OutputPath)" />
<Unzip SourceFiles="$(_ArchivePath)"
DestinationFolder="$(OutputPath)"
Condition="'$(ZigArchiveType)' == 'zip' and !Exists('$(_ArchiveDestination)zig.exe')" />
<Exec Command="tar xf "../../$(_ArchivePath)""
WorkingDirectory="$(OutputPath)"
Condition="'$(ZigArchiveType)' == 'tar.xz' and !Exists('$(_ArchiveDestination)zig')" />
</Target>
<!--
We need to work around some NuGet weirdness where files without an extension
do not get packed properly when using RecursiveDir on its own.
-->
<Target Name="_PackToolset">
<ItemGroup>
<None Include="@(Zig)"
Pack="true"
PackagePath="tools/%(RecursiveDir)%(Filename)%(Extension)"
Condition="'%(Extension)' != ''" />
<None Include="@(Zig)"
Pack="true"
PackagePath="tools/%(RecursiveDir)"
Condition="'%(Extension)' == ''" />
</ItemGroup>
</Target>
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)..'))" />
</Project>