Skip to content

Commit

Permalink
chore: fix integ-test run-from-dist for NuGet packages (#5176)
Browse files Browse the repository at this point in the history
Set local source in a NuGet.Config file instead of hijacking a very
specific sub-command of `dotnet`, which will yield much more stable
operations (all `dotnet` commands that may incur a `restore` operation
will be able to use the "correct" source(s)).
  • Loading branch information
RomainMuller authored Nov 25, 2019
1 parent 29d450d commit bc924bc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
35 changes: 31 additions & 4 deletions packages/aws-cdk/test/integ/run-against-dist.bash
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,43 @@ function prepare_java_packages() {

function prepare_nuget_packages() {
# For NuGet, we wrap the "dotnet" CLI command to use local packages.
log "Hijacking 'dotnet build' command..."
log "Writing new NuGet configuration..."

ORIGINAL_DOTNET=$(type -p dotnet) || { echo "No 'dotnet' found" >&2; exit 1; }
export ORIGINAL_DOTNET
export NUGET_SOURCE=$dist_root/dotnet
local NUGET_SOURCE=$dist_root/dotnet

if [ ! -d "$NUGET_SOURCE" ]; then
echo "NuGet packages missing at $NUGET_SOURCE" >&2
exit 1
fi

mkdir -p $HOME/.nuget/NuGet
if [ -f $HOME/.nuget/NuGet/NuGet.Config ]; then
echo "⚠️ Saving previous NuGet.Config to $HOME/.nuget/NuGet/NuGet.Config.bak"
mv $HOME/.nuget/NuGet/NuGet.Config $HOME/.nuget/NuGet/NuGet.Config.bak
fi

trap clean_up_nuget_config EXIT

cat > $HOME/.nuget/NuGet/NuGet.Config <<EOF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Locally Distributed Packages" value="${NUGET_SOURCE}" />
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
EOF
}

function clean_up_nuget_config() {
log "Restoring NuGet configuration"
if [ -f $HOME/.nuget/NuGet/NuGet.Config.bak ]; then
log "-> Restoring $HOME/.nuget/NuGet/NuGet.Config from $HOME/.nuget/NuGet/NuGet.Config.bak"
mv -f $HOME/.nuget/NuGet/NuGet.Config.bak $HOME/.nuget/NuGet/NuGet.Config
else
log "-> Removing $HOME/.nuget/NuGet/NuGet.Config"
rm -f $HOME/.nuget/NuGet/NuGet.Config
fi
}

# pip_install REQUIREMENTS_FILE
Expand Down
10 changes: 0 additions & 10 deletions packages/aws-cdk/test/integ/run-wrappers/dist/dotnet

This file was deleted.

0 comments on commit bc924bc

Please sign in to comment.