Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .NET Setup
# .NET Restore

![License: MIT][shield-license-mit]
[![CI][shield-ci]][workflow-ci]
Expand Down
21 changes: 11 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ runs:
- name: .NET Restore
working-directory: ${{ inputs.working-directory }}
shell: bash
run: >
dotnet restore
"${{ inputs.workspace }}"
${{ inputs.configfile != '' && format('--configfile "{0}"', inputs.configfile) || '' }}
${{ inputs.ignore-failed-sources != 'false' && '--ignore-failed-sources' || '' }}
${{ inputs.force != 'false' && '--force' || '' }}
${{ inputs.force-evaluate != 'false' && '--force-evaluate' || '' }}
${{ inputs.use-lock-file != 'false' && '--use-lock-file' || '' }}
${{ inputs.lock-file-path != '' && format('--lock-file-path "{0}"', inputs.lock-file-path) || '' }}
${{ inputs.locked-mode != 'false' && '--locked-mode' || '' }}
env:
INPUT_WORKSPACE: ${{ inputs.workspace }}
INPUT_CONFIGFILE: ${{ inputs.configfile }}
INPUT_IGNORE_FAILED_SOURCES: ${{ inputs.ignore-failed-sources != 'false' && 'true' || 'false' }}
INPUT_FORCE: ${{ inputs.force != 'false' && 'true' || 'false' }}
INPUT_FORCE_EVALUATE: ${{ inputs.force-evaluate != 'false' && 'true' || 'false' }}
INPUT_USE_LOCK_FILE: ${{ inputs.use-lock-file != 'false' && 'true' || 'false' }}
INPUT_LOCK_FILE_PATH: ${{ inputs.lock-file-path != 'false' && 'true' || 'false' }}
INPUT_LOCKED_MODE: ${{ inputs.locked-mode != 'false' && 'true' || 'false' }}
run: |
"${{ github.action_path }}/entrypoint.sh"
50 changes: 50 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

set -e
set -o pipefail

if sdk_version=$(dotnet --version 2>&1); then
echo "Using .NET SDK version '$sdk_version'"
else
echo "::error ::The .NET SDK is not installed"
exit 1
fi

if version=$(dotnet restore --version 2>&1); then
echo "Using 'dotnet restore' version '$version'"
else
echo "::error ::The 'dotnet restore' tool is not installed"
exit 1
fi

cmd="dotnet restore"

if [[ -n "$INPUT_CONFIGFILE" ]]; then
cmd+=" --configfile '$INPUT_CONFIGFILE'"
fi

if [[ -n "$INPUT_IGNORE_FAILED_SOURCES" ]]; then
cmd+=" --ignore-failed-sources"
fi

if [[ -n "$INPUT_FORCE" ]]; then
cmd+=" --force"
fi

if [[ -n "$INPUT_FORCE_EVALUATE" ]]; then
cmd+=" --force-evaluate"
fi

if [[ -n "$INPUT_USE_LOCK_FILE" ]]; then
cmd+=" --use-lock-file"
fi

if [[ -n "$INPUT_LOCK_FILE_PATH" ]]; then
cmd+=" --lock-file-path '$INPUT_LOCK_FILE_PATH'"
fi

if [[ -n "$INPUT_LOCKED_MODE" ]]; then
cmd+=" --locked-mode"
fi

eval "$cmd"