-
Notifications
You must be signed in to change notification settings - Fork 694
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
Improve installation of .NET for building NuGet.Client repository #5134
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Each line represents arguments for the .NET SDK installer script (https://learn.microsoft.com/dotnet/core/tools/dotnet-install-script) | ||
-Channel 7.0 | ||
-Channel 6.0 -Runtime dotnet | ||
-Channel 5.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need the 5.0 and 3.1 SDKs? We'll always build with the latest installed SDK anyways. |
||
-Channel 3.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
@echo off | ||
powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -Command "%~dpn0.ps1" %* | ||
powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -Command "%~dpn0.ps1" -SkipDotnetInfo %* | ||
IF ERRORLEVEL 1 ( | ||
EXIT /B %ERRORLEVEL% | ||
) | ||
|
||
SET "DOTNET_ROOT=%~dp0cli" | ||
SET DOTNET_MULTILEVEL_LOOKUP=0 | ||
SET "PATH=%~dp0cli;%PATH%" | ||
dotnet --info | ||
IF ERRORLEVEL 1 ( | ||
ECHO "dotnet --info exited with non-zero exit code" 1>&2 | ||
EXIT /B 1 | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,8 @@ Param ( | |
[switch]$CleanCache, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance while you're at it, you could move the strong name key disable code out of build.ps1 and into configure.ps1? It's something that needs to be configured once per machine, not every build. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I wasn't sure if it needed to be configured unless you want to debug our VSIX? Or is it safe to disable it on everyone's machine that runs this script? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it needs to be disabled not only to run the VSIX, but also to run the .NET Framework restore task, the non-ilmerged nuget.exe (maybe even the ilmerged nuget.exe). I'm not sure about running tests. Maybe it's needed for that too. Basically, I think strong name validation for our 2 keys should be disabled for everyone running the script on Windows. |
||
[Alias('f')] | ||
[switch]$Force, | ||
[switch]$RunTest | ||
[switch]$RunTest, | ||
[switch]$SkipDotnetInfo | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
@@ -42,7 +43,7 @@ Invoke-BuildStep 'Configuring git repo' { | |
} -ev +BuildErrors | ||
|
||
Invoke-BuildStep 'Installing .NET CLI' { | ||
Install-DotnetCLI -Force:$Force | ||
Install-DotnetCLI -Force:$Force -SkipDotnetInfo:$SkipDotnetInfo | ||
} -ev +BuildErrors | ||
|
||
# Restoring tools required for build | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env bash | ||
|
||
CLI_DIR="$(pwd)/cli" | ||
|
||
# Download the CLI install script to cli | ||
echo "Installing .NET SDKs..." | ||
mkdir -p $CLI_DIR | ||
curl -o $CLI_DIR/dotnet-install.sh -L https://dot.net/v1/dotnet-install.sh --silent | ||
if (( $? )); then | ||
echo "Could not download 'dotnet-install.sh' script. Please check your network and try again!" | ||
return 1 | ||
fi | ||
|
||
# Run install.sh for cli | ||
chmod +x $CLI_DIR/dotnet-install.sh | ||
|
||
# If the DOTNET_SDK_VERSIONS environment variable is set, use its value instead of the ones in DotNetSdkVersions.txt | ||
if [ "$DOTNET_SDK_VERSIONS" != "" ]; then | ||
echo "Using environment variable DOTNET_SDK_VERSIONS instead of DotNetSdkVersions.txt. Value: '$DOTNET_SDK_VERSIONS'" | ||
IFS=';' read -ra array <<< "$DOTNET_SDK_VERSIONS" | ||
for CliArgs in "${array[@]}"; | ||
do | ||
echo "'cli/dotnet-install.sh -InstallDir $CLI_DIR -NoPath $CliArgs'" | ||
|
||
cli/dotnet-install.sh -InstallDir $CLI_DIR -NoPath $CliArgs | ||
if (( $? )); then | ||
echo "The .NET install failed!" | ||
return 1 | ||
fi | ||
done | ||
else | ||
# Get CLI Branches for testing | ||
cat build/DotNetSdkVersions.txt | while IFS=$'\r' read -r CliArgs || [[ -n $line ]]; | ||
do | ||
if [ "${CliArgs:0:1}" != "#" ] || [ "$CliArgs" == "" ]; then | ||
echo "'cli/dotnet-install.sh -InstallDir $CLI_DIR -NoPath $CliArgs'" | ||
|
||
cli/dotnet-install.sh -InstallDir $CLI_DIR -NoPath $CliArgs | ||
if (( $? )); then | ||
echo "The .NET install failed!" | ||
return 1 | ||
fi | ||
fi | ||
done | ||
fi | ||
|
||
export DOTNET_ROOT="$CLI_DIR" | ||
export DOTNET_MULTILEVEL_LOOKUP="0" | ||
export "PATH=$CLI_DIR:$PATH" | ||
|
||
if [ "$CI" == "true" ]; then | ||
echo "##vso[task.setvariable variable=DOTNET_ROOT;isOutput=false;issecret=false;]$CLI_DIR" | ||
echo "##vso[task.setvariable variable=DOTNET_MULTILEVEL_LOOKUP;isOutput=false;issecret=false;]0" | ||
echo "##vso[task.prependpath]$CLI_DIR" | ||
fi | ||
|
||
# Display .NET CLI info | ||
dotnet --info | ||
if [ $? -ne 0 ]; then | ||
echo "dotnet is not available on the PATH!" | ||
return 1 | ||
fi | ||
|
||
echo "==================================================================" | ||
|
||
echo "Initializing submodules..." | ||
git submodule init | ||
git submodule update | ||
|
||
echo "Restoring bootstrap packages..." | ||
dotnet msbuild build/bootstrap.proj /Target:Restore | ||
if [ $? -ne 0 ]; then | ||
echo "Bootstrap failed!!" | ||
return 1 | ||
fi | ||
|
||
echo "Restoring NuGet packages..." | ||
dotnet msbuild build/build.proj /Target:Restore "/ConsoleLoggerParameters:Verbosity=Minimal;Summary;ForceNoAlign" /MaxCPUCount /NodeReuse:false | ||
if [ $? -ne 0 ]; then | ||
echo "Restore packages failed!!" | ||
return 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of the
-runtime dotnet
on the line, but not others?We've had contributors using some IBM mainframe contribute to NuGet, but it uses the mono runtime (not Mono Project, that implements .NET Framework, but the mono runtime of the .NET Core App runtime). By specifying
-runtime dotnet
, is it going to cause problems for customers on platforms that the dotnet runtime doesn't have binaries for?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that some of our tests need the .NET 6 runtime but don't need the full SDK. I've experimented a little and hope to trim this down as soon as all of our tests target .NET 7 or .NET 8.