Skip to content

Commit bfa391b

Browse files
PureWeenCopilot
andcommitted
Simplify maccatalyst CLI bundling to single target
SDK 0.1.26 (github/copilot-sdk#485) handles the download mapping, but MAUI still won't bundle the binary because the SDK's ContentWithTargetPath registration lacks PublishFolderType metadata. The fix is a single target that re-registers the item with PublishFolderType=Assembly and a flat TargetPath so MAUI places it in MonoBundle. Replaced 5 custom MSBuild targets (55 lines) with 1 target (10 lines). Verified via clean build: copilot binary lands in .app/Contents/MonoBundle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dd03e4f commit bfa391b

1 file changed

Lines changed: 9 additions & 42 deletions

File tree

PolyPilot/PolyPilot.csproj

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -87,55 +87,22 @@
8787
<TrimmerRootAssembly Include="GitHub.Copilot.SDK" RootMode="All" />
8888
</ItemGroup>
8989

90-
<!-- SDK 0.1.26+ natively maps maccatalyst RIDs for CLI download (issue #454).
91-
The _FixCopilotRidForMacCatalyst workaround is no longer needed. -->
92-
93-
<!-- The SDK (0.1.26+) now maps maccatalyst RIDs to osx RIDs for download.
94-
However, at runtime RuntimeInformation.RuntimeIdentifier returns maccatalyst-arm64,
95-
so the SDK looks for runtimes/maccatalyst-arm64/native/copilot. We still need to
96-
copy the binary to that path AND into the .app bundle's MonoBundle. -->
97-
<Target Name="_CopyCopilotCliForMacCatalyst" AfterTargets="_CopyCopilotCliToOutput" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And '$(_CopilotPlatform)' != ''">
98-
<PropertyGroup>
99-
<_CopilotMacCatalystOutputDir>$(OutDir)runtimes/$(RuntimeIdentifier)/native</_CopilotMacCatalystOutputDir>
100-
<_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli/$(CopilotCliVersion)/$(_CopilotPlatform)</_CopilotCacheDir>
101-
</PropertyGroup>
102-
<MakeDir Directories="$(_CopilotMacCatalystOutputDir)" />
103-
<Copy SourceFiles="$(_CopilotCacheDir)/$(_CopilotBinary)" DestinationFolder="$(_CopilotMacCatalystOutputDir)" SkipUnchangedFiles="true" />
104-
</Target>
105-
106-
<!-- The SDK registers the intermediate copilot binary as ContentWithTargetPath.
107-
On Mac Catalyst this surfaces as a publish metadata warning; we already copy
108-
the binary explicitly via custom targets above. -->
109-
<Target Name="_ExcludeCopilotCliIntermediateFromMacCatalystPublish" AfterTargets="_RegisterCopilotCliForCopy" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And '$(_CopilotPlatform)' != ''">
90+
<!-- The SDK registers the copilot CLI as ContentWithTargetPath but doesn't set
91+
PublishFolderType, so MAUI skips it when building the .app bundle.
92+
Re-register with PublishFolderType=Assembly so it lands in MonoBundle
93+
(where ResolveBundledCliPath finds it). -->
94+
<Target Name="_FixCopilotCliBundling" AfterTargets="_RegisterCopilotCliForCopy" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And '$(_CopilotPlatform)' != ''">
11095
<PropertyGroup>
11196
<_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli/$(CopilotCliVersion)/$(_CopilotPlatform)</_CopilotCacheDir>
11297
</PropertyGroup>
11398
<ItemGroup>
11499
<ContentWithTargetPath Remove="$(_CopilotCacheDir)/$(_CopilotBinary)" />
115100
<ContentWithTargetPath Remove="$(_CopilotCacheDir)\$(_CopilotBinary)" />
101+
<ContentWithTargetPath Include="$(_CopilotCacheDir)/$(_CopilotBinary)"
102+
TargetPath="copilot"
103+
CopyToOutputDirectory="PreserveNewest"
104+
PublishFolderType="Assembly" />
116105
</ItemGroup>
117106
</Target>
118107

119-
<Target Name="_ExcludeCopilotCliFromResolvedPublishForMacCatalyst" BeforeTargets="_ComputePublishLocation" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And '$(_CopilotPlatform)' != ''">
120-
<PropertyGroup>
121-
<_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli/$(CopilotCliVersion)/$(_CopilotPlatform)</_CopilotCacheDir>
122-
</PropertyGroup>
123-
<ItemGroup>
124-
<ResolvedFileToPublish Remove="$(_CopilotCacheDir)/$(_CopilotBinary)" />
125-
<ResolvedFileToPublish Remove="$(_CopilotCacheDir)\$(_CopilotBinary)" />
126-
</ItemGroup>
127-
</Target>
128-
129-
<!-- Ensure the copilot CLI binary is included in the Mac Catalyst .app bundle.
130-
MAUI flattens everything into MonoBundle, so runtimes/ paths don't work.
131-
Copy the binary directly into the .app bundle's MonoBundle. -->
132-
<Target Name="_IncludeCopilotCliInBundle" AfterTargets="Build" Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' And '$(_CopilotPlatform)' != ''">
133-
<PropertyGroup>
134-
<_CopilotCacheDir>$(IntermediateOutputPath)copilot-cli/$(CopilotCliVersion)/$(_CopilotPlatform)</_CopilotCacheDir>
135-
<_AppBundleMonoBundle>$(OutDir)PolyPilot.app/Contents/MonoBundle</_AppBundleMonoBundle>
136-
</PropertyGroup>
137-
<Copy SourceFiles="$(_CopilotCacheDir)/$(_CopilotBinary)" DestinationFolder="$(_AppBundleMonoBundle)" SkipUnchangedFiles="true" Condition="Exists('$(_AppBundleMonoBundle)')" />
138-
<Message Importance="high" Text="Copied copilot CLI binary to app bundle MonoBundle" Condition="Exists('$(_AppBundleMonoBundle)')" />
139-
</Target>
140-
141108
</Project>

0 commit comments

Comments
 (0)