+prepare_solution() {
+ target=$1; [ -z "$target" ] && target="full"
+
+ dotnet new sln -n $SLN_NAME -o $SCRIPT_DIR --force
+ if [ "$target" == "public" -o "$target" == "full" ]; then
+ dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.csproj
+ fi
+ if [ "$target" == "internal" -o "$target" == "full" ]; then
+ dotnet sln $SLN_FILE add $SCRIPT_DIR/internals/src/*/*.csproj
+ fi
+ if [ "$target" == "design" ]; then
+ dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.Design.csproj
+ else
+ dotnet sln $SLN_FILE remove $SCRIPT_DIR/src/*/*.Design.csproj
+ fi
+ if [ "$target" == "xamlbuild" ]; then
+ dotnet sln $SLN_FILE add $SCRIPT_DIR/src/*/*.XamlBuild.csproj
+ else
+ dotnet sln $SLN_FILE remove $SCRIPT_DIR/src/*/*.XamlBuild.csproj
+ fi
+}
+
+cleanup_solution() {
+ rm -f $SLN_FILE
+}
+
+remove_intermediates() {
+ find $1 -type d \
+ \( -name obj -o -name bin \) -print0 | xargs -0 -I {} rm -fr "{}"
+}
+
+clean() {
+ remove_intermediates $SCRIPT_DIR/build/
+ remove_intermediates $SCRIPT_DIR/src/
+ remove_intermediates $SCRIPT_DIR/internals/src/
+ rm -fr $OUTDIR
+ rm -f msbuild.log
+ cleanup_solution
+}
+
+restore() {
+ if [ -d /nuget ]; then
+ dotnet restore -s /nuget $@
+ else
+ dotnet restore $@
+ fi
+}
+
+build() {
+ dotnet build --no-restore -c $CONFIGURATION /fl $@
+}
+
+copy_artifacts() {
+ mkdir -p $2
+ for proj in $(ls -d1 $1/*/); do
+ if [ -d $proj/bin/$CONFIGURATION ]; then
+ cp -fr $proj/bin/$CONFIGURATION/*/* $2
+ fi
+ done
+}
+
+build_artifacts() {
+ copy_artifacts $SCRIPT_DIR/src $OUTDIR/bin/public
+ copy_artifacts $SCRIPT_DIR/internals/src $OUTDIR/bin/internal
+
+ # move preload
+ mkdir -p $OUTDIR/preload
+ mv $OUTDIR/bin/public/*.preload $OUTDIR/preload 2>/dev/null || :
+ mv $OUTDIR/bin/internal/*.preload $OUTDIR/preload 2>/dev/null || :
+
+ # merge filelist
+ for profile in ${PROFILES[@]}; do
+ list=$(cat $OUTDIR/bin/public/*.$profile.filelist \
+ $OUTDIR/bin/internal/*.$profile.filelist \
+ | sort | uniq)
+ rm -f $OUTDIR/$profile.filelist
+ for item in $list; do
+ if [[ "$item" == *.preload ]]; then
+ echo $TARGET_PRELOAD_DIR/$item >> $OUTDIR/$profile.filelist
+ else
+ echo $TARGET_ASSEMBLY_DIR/$item >> $OUTDIR/$profile.filelist
+ fi
+ done
+ done
+}
+
+cmd_module_build() {