Skip to content

Commit 4a8f3c6

Browse files
tlbdktmds
authored andcommitted
Add support for specifying NuGet package sources via DOTNET_RESTORE_SOURCES
1 parent 38a0f24 commit 4a8f3c6

File tree

8 files changed

+30
-4
lines changed

8 files changed

+30
-4
lines changed

1.0/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ a `.s2i/environment` file inside your source code repository.
107107
- the application sources to be in subfolder `DOTNET_ASSEMBLY_NAME` in the deployed
108108
container.
109109
110+
* **DOTNET_RESTORE_SOURCES**
111+
112+
Used to specify the list of NuGet package sources used during the restore operation. This overrides
113+
all of the sources specified in the NuGet.config file.
114+
110115
* **DOTNET_NPM_TOOLS**
111116
112117
Used to specify a list of npm packages to install before building the app.

1.0/s2i/bin/assemble

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ else
3333
APP_DLL_NAME="$(basename "$(realpath "${DOTNET_STARTUP_PROJECT}")").dll"
3434
fi
3535

36+
# Build nuget sources list for when doing the restore
37+
RESTORE_OPTIONS=""
38+
for SOURCE in $DOTNET_RESTORE_SOURCES; do
39+
RESTORE_OPTIONS="$RESTORE_OPTIONS --source $SOURCE"
40+
done
41+
3642
echo "---> Installing dependencies ..."
37-
dotnet restore
43+
dotnet restore $RESTORE_OPTIONS
3844

3945
# The publish operation fails when .NET framework targets are included in project.json
4046
# See https://github.com/dotnet/cli/issues/3636
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
DOTNET_STARTUP_PROJECT=src/app
22
DOTNET_CONFIGURATION=Debug
33
DOTNET_TEST_PROJECTS=test/test1 test/test2
4-
DOTNET_ASSEMBLY_NAME=SampleApp
4+
DOTNET_ASSEMBLY_NAME=SampleApp
5+
DOTNET_RESTORE_SOURCES=https://api.nuget.org/v3/index.json https://www.myget.org/F/s2i-dotnetcore

1.0/test/asp-net-hello-world-envvar/src/app/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
66
"Microsoft.Extensions.Logging.Console": "1.0.0",
77
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
8+
"S2iDotNetCoreDummy": "1.0.1",
89
"lib": "1.0.0-*"
910
},
1011
"buildOptions": {

1.1/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ a `.s2i/environment` file inside your source code repository.
107107
- the application sources to be in subfolder `DOTNET_ASSEMBLY_NAME` in the deployed
108108
container.
109109
110+
* **DOTNET_RESTORE_SOURCES**
111+
112+
Used to specify the list of NuGet package sources used during the restore operation. This overrides
113+
all of the sources specified in the NuGet.config file.
114+
110115
* **DOTNET_NPM_TOOLS**
111116
112117
Used to specify a list of npm packages to install before building the app.

1.1/s2i/bin/assemble

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ else
3333
APP_DLL_NAME="$(basename "$(realpath "${DOTNET_STARTUP_PROJECT}")").dll"
3434
fi
3535

36+
# Build nuget sources list for when doing the restore
37+
RESTORE_OPTIONS=""
38+
for SOURCE in $DOTNET_RESTORE_SOURCES; do
39+
RESTORE_OPTIONS="$RESTORE_OPTIONS --source $SOURCE"
40+
done
41+
3642
echo "---> Installing dependencies ..."
37-
dotnet restore
43+
dotnet restore $RESTORE_OPTIONS
3844

3945
# The publish operation fails when .NET framework targets are included in project.json
4046
# See https://github.com/dotnet/cli/issues/3636
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
DOTNET_STARTUP_PROJECT=src/app
22
DOTNET_CONFIGURATION=Debug
33
DOTNET_TEST_PROJECTS=test/test1 test/test2
4-
DOTNET_ASSEMBLY_NAME=SampleApp
4+
DOTNET_ASSEMBLY_NAME=SampleApp
5+
DOTNET_RESTORE_SOURCES=https://api.nuget.org/v3/index.json https://www.myget.org/F/s2i-dotnetcore

1.1/test/asp-net-hello-world-envvar/src/app/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
66
"Microsoft.Extensions.Logging.Console": "1.1.0",
77
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
8+
"S2iDotNetCoreDummy": "1.0.1",
89
"lib": "1.0.0-*"
910
},
1011
"buildOptions": {

0 commit comments

Comments
 (0)