Skip to content

Commit d9a6207

Browse files
[build] Fix tools//<file> paths in Microsoft.Android.Sdk pack (#11689)
When inspecting `Microsoft.Android.Sdk.Windows.*.nupkg`, every file that lives directly under `tools/` (e.g. `r8.jar`, `aapt2.exe`, `bundletool.jar`, `Xamarin.Android.Build.Tasks.dll`, all the targets files, etc.) is packed with a malformed entry path containing a double slash: tools//r8.jar tools//aapt2.exe tools//bundletool.jar ... 83 of the 281 entries in the package are affected. The cause is in `build-tools/create-packs/Microsoft.Android.Sdk.proj`: ```xml <AndroidSdkBuildTools Include="@(MSBuildItemsWin)" TargetPath="tools\$([System.IO.Path]::GetDirectoryName('%(MSBuildItemsWin.RelativePath)'))" ... /> ``` For an item whose `RelativePath` is just a filename like `r8.jar`, `Path.GetDirectoryName('r8.jar')` returns `""`, so `TargetPath` becomes `tools\` (trailing slash). The `SharedFramework.Sdk` packaging logic then appends `/r8.jar`, producing `tools//r8.jar`. Items with a real subdirectory (e.g. `cs\Foo.resources.dll`, `bcl\Foo.dll`) are unaffected, because the directory name suppresses the trailing-slash issue. Switch to `Path.Combine`, which collapses an empty second argument cleanly: | Input `RelativePath` | Old result | New result | | -------------------------- | ------------- | ------------- | | `r8.jar` | `tools\` ❌ | `tools` ✅ | | `cs\Foo.resources.dll` | `tools\cs` ✅ | `tools\cs` ✅ | | `bcl\Foo.dll` | `tools\bcl` ✅| `tools\bcl` ✅| This bug has been latent since `dc089720b [build] Use SharedFramework.Sdk to create workload packs (#10000)`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ad5cf59 commit d9a6207

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

build-tools/create-packs/Microsoft.Android.Sdk.proj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ core workload SDK packs imported by WorkloadManifest.targets.
4242
DependsOnTargets="ConstructInstallerItems;_GetLicense"
4343
BeforeTargets="GetFilesToPackage" >
4444
<ItemGroup>
45-
<AndroidSdkBuildTools Include="@(MSBuildItemsWin)" TargetPath="tools\$([System.IO.Path]::GetDirectoryName('%(MSBuildItemsWin.RelativePath)'))" Condition=" '$(HostOS)' == 'Windows' " />
46-
<AndroidSdkBuildTools Include="@(MSBuildItemsUnix)" TargetPath="tools\$([System.IO.Path]::GetDirectoryName('%(MSBuildItemsUnix.RelativePath)'))" Condition=" '$(HostOS)' == 'Linux' or '$(HostOS)' == 'Darwin' " />
45+
<!-- Use Path.Combine so files at the root of MSBuildItems* (RelativePath has no directory)
46+
produce 'tools' rather than 'tools\', which would otherwise be packed as 'tools//<file>'. -->
47+
<AndroidSdkBuildTools Include="@(MSBuildItemsWin)" TargetPath="$([System.IO.Path]::Combine('tools', $([System.IO.Path]::GetDirectoryName('%(MSBuildItemsWin.RelativePath)'))))" Condition=" '$(HostOS)' == 'Windows' " />
48+
<AndroidSdkBuildTools Include="@(MSBuildItemsUnix)" TargetPath="$([System.IO.Path]::Combine('tools', $([System.IO.Path]::GetDirectoryName('%(MSBuildItemsUnix.RelativePath)'))))" Condition=" '$(HostOS)' == 'Linux' or '$(HostOS)' == 'Darwin' " />
4749
</ItemGroup>
4850

4951
<GenerateUnixFilePermissions

0 commit comments

Comments
 (0)