-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathuse-local-sdk.sh
More file actions
executable file
·112 lines (93 loc) · 3.34 KB
/
use-local-sdk.sh
File metadata and controls
executable file
·112 lines (93 loc) · 3.34 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Opt in to building PolyPilot against a local copilot-sdk checkout via ProjectReference.
#
# Usage:
# ./use-local-sdk.sh [path-to-sdk] # Create/update Directory.Build.props.local
# ./use-local-sdk.sh --revert # Remove the local override
# ./use-local-sdk.sh --help # Show help
#
# The SDK path defaults to ../copilot-sdk (a sibling directory). Override with:
# ./use-local-sdk.sh /path/to/copilot-sdk
# COPILOT_SDK_PATH=/path/to/copilot-sdk ./use-local-sdk.sh
#
# This is compile-time only: it changes which GitHub.Copilot.SDK project PolyPilot builds
# against. Runtime CLI selection still comes from PolyPilot settings (Global vs Built-in).
set -eo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
OVERRIDE_FILE="$SCRIPT_DIR/Directory.Build.props.local"
usage() {
cat <<EOF
Build PolyPilot against a local copilot-sdk checkout from source.
Usage:
./use-local-sdk.sh [path-to-sdk]
./use-local-sdk.sh --revert
Examples:
./use-local-sdk.sh
./use-local-sdk.sh /Users/you/Projects/copilot-sdk
COPILOT_SDK_PATH=/Users/you/src/copilot-sdk ./use-local-sdk.sh
What this does:
- writes a gitignored Directory.Build.props.local file
- sets CopilotSdkProjectPath to the local GitHub.Copilot.SDK.csproj
- runs dotnet restore so PolyPilot starts building the SDK from source
What it does NOT do:
- it does not modify tracked csproj files or nuget.config
- it does not change PolyPilot's runtime CLI source (Global vs Built-in)
EOF
}
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
usage
exit 0
fi
if [ "$1" = "--revert" ]; then
echo "Removing local copilot-sdk override..."
cd "$SCRIPT_DIR"
if [ -f "$OVERRIDE_FILE" ]; then
rm "$OVERRIDE_FILE"
dotnet restore PolyPilot.slnx --force --nologo
echo "Done. PolyPilot is back to the normal package-based SDK reference."
else
echo "No Directory.Build.props.local file was present. Nothing to do."
fi
exit 0
fi
if [ -n "$1" ]; then
SDK_DIR="$1"
elif [ -n "$COPILOT_SDK_PATH" ]; then
SDK_DIR="$COPILOT_SDK_PATH"
else
SDK_DIR="$SCRIPT_DIR/../copilot-sdk"
fi
SDK_PROJECT="$SDK_DIR/dotnet/src/GitHub.Copilot.SDK.csproj"
if [ ! -f "$SDK_PROJECT" ]; then
echo "Copilot SDK project not found at:"
echo " $SDK_PROJECT"
echo
echo "Clone it first, for example:"
echo " git clone https://github.com/PureWeen/copilot-sdk.git $SDK_DIR"
echo " cd $SDK_DIR && git checkout upstream_validation"
echo
echo "Or pass a custom path:"
echo " ./use-local-sdk.sh /path/to/copilot-sdk"
exit 1
fi
# Canonicalize to absolute path so MSBuild resolves it correctly from any project directory
SDK_PROJECT="$(cd "$(dirname "$SDK_PROJECT")" && pwd)/$(basename "$SDK_PROJECT")"
cd "$SCRIPT_DIR"
cat > "$OVERRIDE_FILE" <<EOF
<Project>
<PropertyGroup>
<!-- Local-only override generated by use-local-sdk.sh. This file is gitignored. -->
<CopilotSdkProjectPath>$SDK_PROJECT</CopilotSdkProjectPath>
</PropertyGroup>
</Project>
EOF
dotnet restore PolyPilot.slnx --force --nologo
echo
echo "PolyPilot is now configured to build GitHub.Copilot.SDK from source:"
echo " $SDK_PROJECT"
echo
echo "This only affects compile-time references."
echo "Runtime CLI selection still comes from PolyPilot settings."
echo
echo "To switch back to the package reference later:"
echo " ./use-local-sdk.sh --revert"