--- /dev/null
+#!/bin/bash
+
+# Usages:
+# dotnet-build.sh build [Target] [Configuration]
+# dotnet-build.sh pack [NuSpec] [Version]
+
+usage() {
+ echo "Usage:"
+ echo " $0 restore TARGET"
+ echo " - TARGET : Project Directory, Solution File(.sln), Project JSON(.project.json)"
+ echo " $0 build TARGET CONFIGURATION"
+ echo " - TARGET : Project Directory, Solution File(.sln), Project File(.csproj)"
+ echo " - CONFIGURATION : Configuration name defined in .csproj (Debug, Release)"
+ echo " $0 pack NUSPEC VERSION CONFIGURATION"
+ echo " - NUSPEC : .nuspec file path"
+ echo " - VERSION : Version of nuget package to be created"
+ echo " - CONFIGURATION : Configuration name defined in .csproj (Debug, Release)"
+}
+
+exit_on_error() {
+ if [ $1 -ne 0 ]; then
+ echo "Error $1"
+ exit $1
+ fi
+}
+
+nuget_retry() {
+ local RETRY=3
+ local RET=0
+ local n=0
+ until [ $n -ge $RETRY ]; do
+ if [ $n -gt 0 ]; then
+ sleep 2
+ echo "Retry $n ....."
+ fi
+ echo "+ nuget $@"
+ nuget $@
+ RET=$?
+ if [ $RET -eq 0 ]; then
+ break
+ fi
+ n=$[$n+1]
+ done
+ exit_on_error $RET
+}
+
+cs_build() {
+ echo "+ xbuild $@"
+ xbuild $@
+ exit_on_error $?
+}
+
+restore() {
+ local TARGET=$1; shift
+
+ if [[ $TARGET == *".sln" ]]; then
+ nuget_retry restore $TARGET $@
+ elif [[ $TARGET == *".project.json" ]]; then
+ nuget_retry restore $TARGET $@
+ else
+ local PROJFILES=$(find $TARGET -name "*.project.json")
+ for P in $PROJFILES; do
+ nuget_retry restore $P $@
+ done
+ fi
+}
+
+build_solution() {
+ local TARGET=$1; shift
+ local CONFIGURATION=$1; shift
+
+ cs_build $TARGET /p:Configuration=$CONFIGURATION $@
+}
+
+build_project() {
+ local TARGET=$1; shift
+ local CONFIGURATION=$1; shift
+
+ local PROJECT=${TARGET%.*}
+ local PROJECT_JSON=$PROJECT.project.json
+ if [ -f $PROJECT_JSON ]; then
+ restore $PROJECT_JSON
+ fi
+ cs_build $TARGET /p:Configuration=$CONFIGURATION $@
+}
+
+build() {
+ local TARGET=$1; shift
+ local CONFIGURATION=$1; shift
+
+ if [[ $TARGET == *".sln" ]]; then
+ build_solution $TARGET $CONFIGURATION $@
+ elif [[ $TARGET == *".csproj" ]]; then
+ build_project $TARGET $CONFIGURATION $@
+ else
+ local PROJFILES=$(find $TARGET -name "*.csproj")
+ for P in $PROJFILES; do
+ build_project $P $CONFIGURATION $@
+ done
+ fi
+}
+
+pack() {
+ local NUSPEC=$1; shift
+ local VERSION=$1; shift
+ local CONFIGURATION=$1; shift
+
+ if [ -f $NUSPEC ]; then
+ nuget_retry pack $NUSPEC -Version $VERSION -Properties Configuration=$CONFIGURATION
+ fi
+}
+
+CMD=$1; shift
+case $CMD in
+ restore)
+ if [ $# -ge 1 ]; then
+ restore $@
+ exit 0
+ fi
+ ;;
+ build)
+ if [ $# -ge 2 ]; then
+ build $@
+ exit 0
+ fi
+ ;;
+ pack)
+ if [ $# -ge 3 ]; then
+ pack $@
+ exit 0
+ fi
+ ;;
+esac
+
+usage; exit 1
Name: dotnet-build-tools
Summary: Tools for building C# API projects
-Version: 1.0.10
+Version: 1.0.11
Release: 1
Group: Development/Libraries
License: MIT and Apache-2.0
%install
%define NuGetDir %{_datadir}/NuGet
%define XBuildDir /usr/lib/mono/xbuild
+%define ToolsDir %{_datadir}/DotnetBuildTools
# Tizen.GBS.BuildTasks
mkdir -p %{buildroot}%{XBuildDir}/14.0/Microsoft.Common.targets/ImportAfter
mkdir -p %{buildroot}/nuget
install -p -m 644 LocalPackages/*.nupkg %{buildroot}/nuget
+# BuildTools
+mkdir -p %{buildroot}%{ToolsDir}
+install -p -m 755 Tools/dotnet-build.sh %{buildroot}%{ToolsDir}
+ln -s %{ToolsDir}/dotnet-build.sh %{buildroot}%{_bindir}/dotnet-build
+
# RPM Macros
install -D -p -m 0644 %{S:1} %{buildroot}%{_sysconfdir}/rpm/macros.dotnet-build-tools
%{_bindir}/*
%{NuGetDir}/*
%{XBuildDir}/*
+%{ToolsDir}/*
/nuget/*.nupkg
-
%package mono\
Summary: %{name} for Mono Runtime\
Group: Development/Libraries\
+AutoReqProv: no\
%description mono\
%{name} for Mono Runtime\
%files mono\
%endif \
%{nil}
+%dotnet_restore() \
+dotnet-build restore %{1} \
+%{nil}
+
%dotnet_build() \
-find %{1}/*.project.json -print0 | xargs -n1 -0 nuget restore \
-find %{1}/*.csproj -print0 | xargs -n1 -0 xbuild /p:Configuration=%{_dotnet_build_conf} \
+dotnet-build build %{1} %{_dotnet_build_conf} %{?2} %{?3} %{?4} %{?5} %{?6} \
%{nil}
%dotnet_pack() \
-nuget pack %{1} -Version %{?2}%{!?2:%{version}} -Properties Configuration=%{_dotnet_build_conf} \
+dotnet-build pack %{1} %{2} %{_dotnet_build_conf} %{?3} %{?4} %{?5} %{?6} %{?7} \
%{nil}
%dotnet_install() \