Skip to content

Commit 163640f

Browse files
committed
Work around a NuGet issue.
1 parent b16906e commit 163640f

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

src/Directory.Build.targets

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
<Project>
2+
<PropertyGroup>
3+
<BeforePack>_PackToolset</BeforePack>
4+
</PropertyGroup>
5+
6+
<PropertyGroup>
7+
<_ArchiveBase>zig-$(ZigArchiveName)-$(Version)</_ArchiveBase>
8+
<_ArchiveName>$(_ArchiveBase).$(ZigArchiveType)</_ArchiveName>
9+
<_ArchivePath>$(OutputPath)$(_ArchiveName)</_ArchivePath>
10+
<_ArchiveDestination>$(OutputPath)$(_ArchiveBase)/</_ArchiveDestination>
11+
</PropertyGroup>
12+
213
<ItemGroup>
3-
<None Include="build/**/*"
4-
Pack="true"
5-
PackagePath="%(RelativeDir)" />
6-
<None Include="bin/$(Configuration)/zig-$(ZigArchiveName)-$(Version)/**/*"
14+
<None Include="build/**"
715
Pack="true"
8-
PackagePath="tools/%(RecursiveDir)" />
16+
PackagePath="%(Identity)" />
917
</ItemGroup>
1018

19+
<ItemGroup>
20+
<Zig Include="$(_ArchiveDestination)**" />
21+
</ItemGroup>
22+
23+
<!--
24+
TODO: We currently assume that the tar program can extract XZ archives. This
25+
is not the case for the tar that ships with Windows. So, this target only
26+
really works on Unix systems or in environments that have a proper tar (e.g.
27+
Git Bash).
28+
-->
1129
<Target Name="_RestoreArchive"
1230
AfterTargets="_GenerateRestoreProjectPathWalk">
13-
<PropertyGroup>
14-
<_ArchiveBase>zig-$(ZigArchiveName)-$(Version)</_ArchiveBase>
15-
<_ArchiveName>$(_ArchiveBase).$(ZigArchiveType)</_ArchiveName>
16-
<_ArchivePath>$(OutputPath)$(_ArchiveName)</_ArchivePath>
17-
<_ArchiveDestination>$(OutputPath)$(_ArchiveBase)/</_ArchiveDestination>
18-
</PropertyGroup>
19-
2031
<DownloadFile SourceUrl="https://ziglang.org/download/$(Version)/$(_ArchiveName)"
2132
DestinationFolder="$(OutputPath)"
2233
Condition="!Exists('$(_ArchivePath)')" />
@@ -32,5 +43,22 @@
3243
Condition="'$(ZigArchiveType)' == 'tar.xz' and !Exists('$(_ArchiveDestination)zig')" />
3344
</Target>
3445

46+
<!--
47+
We need to work around some NuGet weirdness where files without an extension
48+
do not get packed properly when using RecursiveDir on its own.
49+
-->
50+
<Target Name="_PackToolset">
51+
<ItemGroup>
52+
<None Include="@(Zig)"
53+
Pack="true"
54+
PackagePath="tools/%(RecursiveDir)%(Filename)%(Extension)"
55+
Condition="'%(Extension)' != ''" />
56+
<None Include="@(Zig)"
57+
Pack="true"
58+
PackagePath="tools/%(RecursiveDir)"
59+
Condition="'%(Extension)' == ''" />
60+
</ItemGroup>
61+
</Target>
62+
3563
<Import Project="$([MSBuild]::GetPathOfFileAbove('$(MSBuildThisFile)', '$(MSBuildThisFileDirectory)..'))" />
3664
</Project>

0 commit comments

Comments
 (0)