1+ #! /usr/bin/env bash
2+ # ------------------------------------------------------------------------------
3+ # Pack a .NET solution (or current folder), generate a LocalOnly.NuGet.Config
4+ # inside the feed directory (so it won't affect the solution), and install
5+ # (or reinstall) the Uno.Check global tool from that feed.
6+ #
7+ # Usage:
8+ # ./pack-and-install.sh [Solution] [LocalFeed]
9+ #
10+ # Solution: Optional path to a .sln file or project folder.
11+ # If omitted, dotnet pack runs on the current directory.
12+ # LocalFeed: Optional directory to emit nupkg files into.
13+ # If omitted, defaults to 'LocalFeed' in the script folder.
14+ # ------------------------------------------------------------------------------
15+
16+ set -euo pipefail
17+
18+ PackageId=" Uno.Check"
19+
20+ # Determine script directory
21+ scriptDir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
22+ cd " $scriptDir "
23+
24+ Solution=" ${1:- } "
25+ LocalFeed=" ${2:- } "
26+
27+ if [[ -z " $Solution " ]]; then
28+ echo " No solution specified → packing current directory"
29+ packTarget=" ."
30+ else
31+ packTarget=" $Solution "
32+ fi
33+
34+ if [[ -z " $LocalFeed " ]]; then
35+ LocalFeed=" LocalFeed"
36+ echo " No feed directory specified → using default '$LocalFeed '"
37+ fi
38+
39+ # Ensure feed directory exists
40+ if [[ ! -d " $LocalFeed " ]]; then
41+ echo " Creating feed directory: $LocalFeed "
42+ mkdir -p " $LocalFeed "
43+ fi
44+
45+ echo " Packing '$packTarget ' to '$LocalFeed '..."
46+ dotnet pack " $packTarget " -c Release -o " $LocalFeed "
47+
48+ # Place NuGet.Config inside the feed directory
49+ configFile=" $LocalFeed /LocalOnly.NuGet.Config"
50+ feedUri=" $( cd " $LocalFeed " && pwd) "
51+
52+ echo " Generating NuGet.Config at '$configFile '..."
53+ cat > " $configFile " << EOF
54+ <?xml version="1.0" encoding="utf-8"?>
55+ <configuration>
56+ <packageSources>
57+ <!-- only your local folder -->
58+ <add key="LocalFeed" value="$feedUri " />
59+ </packageSources>
60+ </configuration>
61+ EOF
62+
63+ # If Uno.Check is already installed, uninstall it first
64+ if dotnet tool list --global | grep -q " ^\s*$PackageId \s" ; then
65+ echo " Detected existing installation of '$PackageId '. Uninstalling..."
66+ dotnet tool uninstall --global " $PackageId "
67+ fi
68+
69+ echo " Installing tool '$PackageId ' using only '$configFile '..."
70+ dotnet tool install --global " $PackageId " \
71+ --configfile " $configFile " \
72+ --ignore-failed-sources
73+
74+ echo
75+ echo " Done. '$PackageId ' is installed from your local feed."
76+
77+ # Prevent the script window from closing immediately
78+ echo
79+ read -p " Press Enter to exit..."
0 commit comments