Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make update-sln diff aware #15

Merged
merged 1 commit into from
May 7, 2019
Merged
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
18 changes: 15 additions & 3 deletions src/scripts/update-sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/usr/bin/env bash

rm -rf *.sln 1>/dev/null
dotnet new sln
find . -name *.csproj | xargs dotnet sln add
__contains() { for item in "${@:2}"; do [[ "$item" == "$1" ]] && return 0; done; return 1; }

for SLN in *.sln; do
EXISTING=($(dotnet sln "$SLN" list))
EXISTING=("${EXISTING[@]:2}")
DISCOVERED=($(find * -name '*.csproj' ! -path '*/bin/*' ! -path '*/obj/*' ! -path '*/shared/*' ))

for existing in "${EXISTING[@]}"; do
__contains $existing "${DISCOVERED[@]}" || dotnet sln "$SLN" remove "$existing"
done

for discovered in "${DISCOVERED[@]}"; do
__contains $discovered "${EXISTING[@]}" || dotnet sln "$SLN" add "$discovered"
done
done