diff --git a/Directory.Packages.props b/Directory.Packages.props index 1ffb3c9e065..e1eeef9d9ea 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -28,7 +28,7 @@ - + diff --git a/build.sh b/build.sh index 0b796d0b7c6..06166461431 100755 --- a/build.sh +++ b/build.sh @@ -8,84 +8,19 @@ while true ; do esac done -RESULTCODE=0 - -# Download the CLI install script to cli -echo "Installing dotnet CLI" -mkdir -p cli -curl -o cli/dotnet-install.sh -L https://dot.net/v1/dotnet-install.sh - -if (( $? )); then - echo "Could not download 'dotnet-install.sh' script. Please check your network and try again!" - exit 1 -fi - -# Run install.sh for cli -chmod +x cli/dotnet-install.sh - -# Get recommended version for bootstrapping testing version -cli/dotnet-install.sh -i cli -c 2.2 -nopath - -if (( $? )); then - echo "The .NET CLI Install failed!!" - exit 1 +# Run configure which installs the .NET SDK +. ./configure.sh +if [ $? -ne 0 ]; then + echo "configure.sh failed !!" + exit 1 fi -# Disable .NET CLI Install Lookup -DOTNET_MULTILEVEL_LOOKUP=0 - -DOTNET="$(pwd)/cli/dotnet" - -# Let the dotnet cli expand and decompress first if it's a first-run -$DOTNET --info - -# Get CLI Branches for testing -echo "dotnet msbuild build/config.props /restore:false /ConsoleLoggerParameters:Verbosity=Minimal;NoSummary;ForceNoAlign /nologo /target:GetCliBranchForTesting" - -IFS=$'\n' -CMD_OUT_LINES=(`dotnet msbuild build/config.props /restore:false /ConsoleLoggerParameters:Verbosity=Minimal;NoSummary;ForceNoAlign /nologo /target:GetCliBranchForTesting`) -# Take only last the line which has the version information and strip all the spaces -DOTNET_BRANCHES=${CMD_OUT_LINES[-1]//[[:space:]]} -unset IFS - -IFS=$';' -for DOTNET_BRANCH in ${DOTNET_BRANCHES[@]} -do - echo $DOTNET_BRANCH - - IFS=$':' - ChannelAndVersion=($DOTNET_BRANCH) - Channel=${ChannelAndVersion[0]} - if [ ${#ChannelAndVersion[@]} -eq 1 ] - then - Version="latest" - else - Version=${ChannelAndVersion[1]} - fi - unset IFS - - echo "Channel is: $Channel" - echo "Version is: $Version" - cli/dotnet-install.sh -i cli -c $Channel -v $Version -nopath - - if (( $? )); then - echo "The .NET CLI Install for $DOTNET_BRANCH failed!!" - exit 1 - fi -done - -# Display .NET CLI info -$DOTNET --info - -echo "=================" - # init the repo git submodule init git submodule update # clear caches -if [ "$CLEAR_CACHE" == "1" ] -then +if [ "$CLEAR_CACHE" == "1" ]; then # echo "Clearing the nuget web cache folder" # rm -r -f ~/.local/share/NuGet/* @@ -96,6 +31,7 @@ fi # restore packages echo "dotnet msbuild build/bootstrap.proj /t:Restore" dotnet msbuild build/bootstrap.proj /t:Restore + echo "dotnet msbuild build/build.proj /t:Restore /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta" dotnet msbuild build/build.proj /t:Restore /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta @@ -112,5 +48,3 @@ if [ $? -ne 0 ]; then echo "Tests failed!!" exit 1 fi - -exit $RESULTCODE diff --git a/build/DotNetSdkVersions.txt b/build/DotNetSdkVersions.txt new file mode 100644 index 00000000000..79d232ec521 --- /dev/null +++ b/build/DotNetSdkVersions.txt @@ -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 +-Channel 3.1 diff --git a/build/common.ps1 b/build/common.ps1 index 764bb9208b1..7cadf12a6e7 100644 --- a/build/common.ps1 +++ b/build/common.ps1 @@ -154,46 +154,34 @@ Function Update-Submodules { Function Install-DotnetCLI { [CmdletBinding()] param( - [switch]$Force + [switch]$Force, + [switch]$SkipDotnetInfo ) - $MSBuildExe = Get-MSBuildExe - - $CmdOutLines = ((& $msbuildExe $NuGetClientRoot\build\config.props /restore:false "/ConsoleLoggerParameters:Verbosity=Minimal;NoSummary;ForceNoAlign" /nologo /target:GetCliBranchForTesting) | Out-String).Trim() - $CliBranchListForTesting = ($CmdOutLines -split [Environment]::NewLine)[-1] - $CliBranchList = $CliBranchListForTesting -split ';' $DotNetInstall = Join-Path $CLIRoot 'dotnet-install.ps1' #If "-force" is specified, or dotnet.exe under cli folder doesn't exist, create cli folder and download dotnet-install.ps1 into cli folder. if ($Force -or -not (Test-Path $DotNetExe)) { - Trace-Log "Downloading .NET CLI '$CliBranchList'" + Trace-Log "Downloading .NET CLI install script" New-Item -ItemType Directory -Force -Path $CLIRoot | Out-Null Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile $DotNetInstall } + if (-not ([string]::IsNullOrEmpty($env:DOTNET_SDK_VERSIONS))) { + Trace-Log "Using environment variable DOTNET_SDK_VERSIONS instead of DotNetSdkVersions.txt. Value: '$env:DOTNET_SDK_VERSIONS'" + $CliBranchList = $env:DOTNET_SDK_VERSIONS -Split ";" + } else { + $CliBranchList = (Get-Content -Path "$NuGetClientRoot\build\DotNetSdkVersions.txt") + } + ForEach ($CliBranch in $CliBranchList) { $CliBranch = $CliBranch.trim() - $CliChannelAndVersion = $CliBranch -split ":" - - # If version is not specified, use 'latest' as the version. - $Channel = $CliChannelAndVersion[0].trim() - if ($CliChannelAndVersion.count -eq 1) { - $Version = 'latest' - } - else { - $Version = $CliChannelAndVersion[1].trim() - } - - $cli = @{ - Root = $CLIRoot - Version = $Version - Channel = $Channel + if ($CliBranch.StartsWith("#") -or $CliBranch.Equals("")) { + continue } - $DotNetExe = Join-Path $cli.Root 'dotnet.exe'; - if ([Environment]::Is64BitOperatingSystem) { $arch = "x64"; } @@ -201,18 +189,20 @@ Function Install-DotnetCLI { $arch = "x86"; } - Trace-Log "$DotNetInstall -Channel $($cli.Channel) -InstallDir $($cli.Root) -Version $($cli.Version) -Architecture $arch -NoPath" + Trace-Log "$DotNetInstall $CliBranch -InstallDir $CLIRoot -Architecture $arch -NoPath" - & powershell $DotNetInstall -Channel $cli.Channel -InstallDir $cli.Root -Version $cli.Version -Architecture $arch -NoPath + & powershell $DotNetInstall $CliBranch -InstallDir $CLIRoot -Architecture $arch -NoPath if ($LASTEXITCODE -ne 0) { throw "dotnet-install.ps1 exited with non-zero exit code" } + } + + if (-not (Test-Path $DotNetExe)) { + Error-Log "Unable to find dotnet.exe. The CLI install may have failed." -Fatal + } - if (-not (Test-Path $DotNetExe)) { - Error-Log "Unable to find dotnet.exe. The CLI install may have failed." -Fatal - } - + if ($SkipDotnetInfo -ne $true) { # Display build info & $DotNetExe --info if ($LASTEXITCODE -ne 0) @@ -220,25 +210,17 @@ Function Install-DotnetCLI { throw "dotnet --info exited with non-zero exit code" } } - - # Install the 3.x runtime because our tests target netcoreapp2x - Trace-Log "$DotNetInstall -Runtime dotnet -Channel 3.1 -InstallDir $CLIRoot -NoPath" - # dotnet-install might make http requests that fail, but it handles those errors internally - # However, Invoke-BuildStep checks if any error happened, ever. Hence we need to run dotnet-install - # in a different process, to avoid treating their handled errors as build errors. - & powershell $DotNetInstall -Runtime dotnet -Channel 3.1 -InstallDir $CLIRoot -NoPath - & powershell $DotNetInstall -Runtime dotnet -Channel 5.0 -InstallDir $CLIRoot -NoPath - - if ($LASTEXITCODE -ne 0) - { - throw "dotnet-install.ps1 exited with non-zero exit code" - } - - # Display build info - & $DotNetExe --info - if ($LASTEXITCODE -ne 0) - { - throw "dotnet --info exited with non-zero exit code" + + if ($env:CI -eq "true") { + Write-Host "##vso[task.setvariable variable=DOTNET_ROOT;isOutput=false;issecret=false;]$CLIRoot" + Write-Host "##vso[task.setvariable variable=DOTNET_MULTILEVEL_LOOKUP;isOutput=false;issecret=false;]0" + Write-Host "##vso[task.prependpath]$CLIRoot" + } else { + $env:DOTNET_ROOT=$CLIRoot + $env:DOTNET_MULTILEVEL_LOOKUP=0 + if (-not $env:path.Contains($CLIRoot)) { + $env:path = $CLIRoot + ";" + $env:path + } } } diff --git a/build/config.props b/build/config.props index 23fc005a03d..5f215660d7c 100644 --- a/build/config.props +++ b/build/config.props @@ -35,16 +35,6 @@ rel/d$(VsTargetMajorVersion).$(MinorNuGetVersion) int.d$(VsTargetMajorVersion).$(MinorNuGetVersion) - - 7.0 @@ -90,7 +80,4 @@ - - - diff --git a/configure.cmd b/configure.cmd index 0eb18fc5346..a10470b971d 100644 --- a/configure.cmd +++ b/configure.cmd @@ -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 +) \ No newline at end of file diff --git a/configure.ps1 b/configure.ps1 index 4ae5148d4d7..c511b10c63a 100644 --- a/configure.ps1 +++ b/configure.ps1 @@ -26,7 +26,8 @@ Param ( [switch]$CleanCache, [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 diff --git a/configure.sh b/configure.sh new file mode 100644 index 00000000000..cf8583c380d --- /dev/null +++ b/configure.sh @@ -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 diff --git a/eng/pipelines/templates/CrossFramework_Tests_On_Windows.yml b/eng/pipelines/templates/CrossFramework_Tests_On_Windows.yml index ad946e7c7c5..50002091532 100644 --- a/eng/pipelines/templates/CrossFramework_Tests_On_Windows.yml +++ b/eng/pipelines/templates/CrossFramework_Tests_On_Windows.yml @@ -1,11 +1,4 @@ steps: -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - packageType: sdk - version: 7.x - installationPath: $(Agent.TempDirectory)/dotnet - - task: PowerShell@2 displayName: "Print Environment Variables" inputs: diff --git a/eng/pipelines/templates/Tests_On_Linux.yml b/eng/pipelines/templates/Tests_On_Linux.yml index bb9c9b1d2e3..0e99b480728 100644 --- a/eng/pipelines/templates/Tests_On_Linux.yml +++ b/eng/pipelines/templates/Tests_On_Linux.yml @@ -1,11 +1,4 @@ steps: -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - packageType: sdk - version: 7.x - installationPath: $(Agent.TempDirectory)/dotnet - - task: ShellScript@2 displayName: "Run Tests (continue on error)" continueOnError: "true" diff --git a/eng/pipelines/templates/Tests_On_Mac.yml b/eng/pipelines/templates/Tests_On_Mac.yml index 396d57d1058..a1896d75907 100644 --- a/eng/pipelines/templates/Tests_On_Mac.yml +++ b/eng/pipelines/templates/Tests_On_Mac.yml @@ -1,11 +1,4 @@ steps: -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - packageType: sdk - version: 7.x - installationPath: $(Agent.TempDirectory)/dotnet - - task: DownloadBuildArtifacts@0 displayName: "Download NuGet.CommandLine.Test artifacts" inputs: @@ -38,7 +31,7 @@ steps: searchFolder: "$(Build.Repository.LocalPath)/build/TestResults" mergeTestResults: "true" testRunTitle: "NuGet.Client Tests On Mac" - condition: "succeededOrFailed()" + condition: "always()" - task: PublishBuildArtifacts@1 displayName: "Publish Test Freeze Dump" @@ -46,7 +39,7 @@ steps: PathtoPublish: "$(Build.Repository.LocalPath)/build/TestResults" ArtifactName: "$(Agent.JobName)" ArtifactType: "Container" - condition: "failed()" + condition: "or(failed(), canceled())" - task: PowerShell@2 displayName: "Initialize Git Commit Status on GitHub" diff --git a/scripts/funcTests/runFuncTests.sh b/scripts/funcTests/runFuncTests.sh index d7f2a0c1cd0..79f6d0a1e11 100644 --- a/scripts/funcTests/runFuncTests.sh +++ b/scripts/funcTests/runFuncTests.sh @@ -1,225 +1,100 @@ #!/usr/bin/env bash -echo "Starting runFuncTests at `date -u +"%Y-%m-%dT%H:%M:%S"`" - -env | sort - -while true ; do - case "$1" in - -c|--clear-cache) CLEAR_CACHE=1 ; shift ;; - --) shift ; break ;; - *) shift ; break ;; - esac -done - -RESULTCODE=0 - -# print openssl version -echo "===================================================================================================" -openssl version -a -echo "===================================================================================================" # move up to the repo root SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR=$SCRIPTDIR/../.. pushd $DIR/ -mono --version - -dotnet --info - -# Download the CLI install script to cli -echo "Installing dotnet CLI" -mkdir -p cli -curl -o cli/dotnet-install.sh -L https://dot.net/v1/dotnet-install.sh - -# Run install.sh -chmod +x cli/dotnet-install.sh - -# Disable .NET CLI Install Lookup -DOTNET_MULTILEVEL_LOOKUP=0 - -DOTNET="$(pwd)/cli/dotnet" - -# Let the dotnet cli expand and decompress first if it's a first-run -$DOTNET --info - -# Get CLI Branches for testing -echo "dotnet msbuild build/config.props /restore:false /ConsoleLoggerParameters:Verbosity=Minimal;NoSummary;ForceNoAlign /nologo /target:GetCliBranchForTesting" - -IFS=$'\n' -CMD_OUT_LINES=(`dotnet msbuild build/config.props /restore:false "/ConsoleLoggerParameters:Verbosity=Minimal;NoSummary;ForceNoAlign" /nologo /target:GetCliBranchForTesting`) -# Take only last the line which has the version information and strip all the spaces -CMD_LAST_LINE=${CMD_OUT_LINES[@]:(-1)} -DOTNET_BRANCHES=${CMD_LAST_LINE//[[:space:]]} -unset IFS - -IFS=$';' -for DOTNET_BRANCH in ${DOTNET_BRANCHES[@]} -do - echo $DOTNET_BRANCH - - IFS=$':' - ChannelAndVersion=($DOTNET_BRANCH) - Channel=${ChannelAndVersion[0]} - if [ ${#ChannelAndVersion[@]} -eq 1 ] - then - Version="latest" - else - Version=${ChannelAndVersion[1]} - fi - unset IFS - - echo "cli/dotnet-install.sh --install-dir cli --channel $Channel --version $Version -nopath" - cli/dotnet-install.sh --install-dir cli --channel $Channel --version $Version -nopath - - if (( $? )); then - echo "The .NET CLI Install for $DOTNET_BRANCH failed!!" - exit 1 - fi -done - -# Display .NET CLI info -$DOTNET --info -if (( $? )); then - echo "DOTNET --info failed!!" - exit 1 +LOG_DIRECTORY=$BUILD_STAGINGDIRECTORY +if [ "$LOG_DIRECTORY" == "" ]; then + LOG_DIRECTORY="$(pwd)/.test" fi -# Install .NET 5, 6, and .NETCoreapp3.1 runtimes - -echo "cli/dotnet-install.sh --install-dir cli --runtime dotnet --channel 6.0 -nopath" -cli/dotnet-install.sh --install-dir cli --runtime dotnet --channel 6.0 -nopath - -echo "cli/dotnet-install.sh --install-dir cli --runtime dotnet --channel 5.0 -nopath" -cli/dotnet-install.sh --install-dir cli --runtime dotnet --channel 5.0 -nopath - -echo "cli/dotnet-install.sh --install-dir cli --runtime dotnet --channel 3.1 -nopath" -cli/dotnet-install.sh --install-dir cli --runtime dotnet --channel 3.1 -nopath - -if (( $? )); then - echo "The .NET CLI Install failed!!" - exit 1 -fi - -# Display .NET CLI info -$DOTNET --info -if (( $? )); then - echo "DOTNET --info failed!!" - exit 1 +if [ "$TestResultsDir" == "" ]; then + TestResultsDir="$(pwd)/.test" fi -echo "initial dotnet cli install finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" - -echo "=================" - -echo "Deleting .NET Core temporary files" -rm -rf "/tmp/"dotnet.* - -echo "second dotnet cli install finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" -echo "=================" - -#restore solution packages -dotnet msbuild -t:restore "$DIR/build/bootstrap.proj" -bl:"$BUILD_STAGINGDIRECTORY/binlog/01.RestoreBootstrap.binlog" +# Run configure which installs the .NET SDK +. ./configure.sh if [ $? -ne 0 ]; then - echo "Restore failed!!" + echo "configure.sh failed !!" exit 1 fi -echo "bootstrap project restore finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" - -# init the repo - -git submodule init -git submodule update - -echo "git submodules updated finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" - -# clear caches -if [ "$CLEAR_CACHE" == "1" ] -then - # echo "Clearing the nuget web cache folder" - # rm -r -f ~/.local/share/NuGet/* - - echo "Clearing the nuget packages folder" - rm -r -f ~/.nuget/packages/* -fi - -# restore packages -echo "dotnet msbuild build/build.proj /restore:false /target:Restore /property:Configuration=Release /property:ReleaseLabel=beta /bl:$BUILD_STAGINGDIRECTORY/binlog/02.Restore.binlog" -dotnet msbuild build/build.proj /restore:false /target:Restore /target:Restore /property:Configuration=Release /property:ReleaseLabel=beta /bl:$BUILD_STAGINGDIRECTORY/binlog/02.Restore.binlog - -if [ $? -ne 0 ]; then - echo "Restore failed!!" - exit 1 -fi - -echo "Restore finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" - -# Unit tests -echo "dotnet msbuild build/build.proj /restore:false /target:CoreUnitTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$BUILD_STAGINGDIRECTORY/binlog/03.CoreUnitTests.binlog" -dotnet msbuild build/build.proj /restore:false /target:CoreUnitTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$BUILD_STAGINGDIRECTORY/binlog/03.CoreUnitTests.binlog +echo "=============== Build and run unit tests started at `date -u +"%Y-%m-%dT%H:%M:%S"` =================" +echo "dotnet msbuild build/build.proj /restore:false /target:CoreUnitTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$LOG_DIRECTORY/binlog/03.CoreUnitTests.binlog" +dotnet msbuild build/build.proj /restore:false /target:CoreUnitTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$LOG_DIRECTORY/binlog/03.CoreUnitTests.binlog +UNIT_TEST_RESULT=$? +echo "=============== Build and run unit tests finished at `date -u +"%Y-%m-%dT%H:%M:%S"`=================" +echo "" + +echo "============ Build and run functional tests started at `date -u +"%Y-%m-%dT%H:%M:%S"` ==============" +echo "dotnet msbuild build/build.proj /restore:false /target:CoreFuncTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$LOG_DIRECTORY/binlog/04.CoreFuncTests.binlog" +dotnet msbuild build/build.proj /restore:false /target:CoreFuncTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$LOG_DIRECTORY/binlog/04.CoreFuncTests.binlog +FUNC_TEST_RESULT=$? +echo "============== Build and run functional tests finished at `date -u +"%Y-%m-%dT%H:%M:%S"`============" +echo "" + +MONO_TEST_RESULT=-1 +if [ "$CI" == "true" ]; then + # Run mono test + TestDir="$DIR/artifacts/NuGet.CommandLine.Test/" + VsTestConsole="$DIR/artifacts/NuGet.CommandLine.Test/vstest/vstest.console.exe" + TestResultsDir="$DIR/build/TestResults" + VsTestVerbosity="minimal" + + if [ "$SYSTEM_DEBUG" == "true" ]; then + VsTestVerbosity="detailed" + fi -if [ $? -ne 0 ]; then - echo "CoreUnitTests failed!!" - RESULTCODE=1 + #Clean System dll + rm -rf "$TestDir/System.*" "$TestDir/WindowsBase.dll" "$TestDir/Microsoft.CSharp.dll" "$TestDir/Microsoft.Build.Engine.dll" + + case "$(uname -s)" in + Linux) + # We are not testing Mono on linux currently, so comment it out. + #echo "mono $VsTestConsole $TestDir/NuGet.CommandLine.Test.dll --TestCaseFilter:Platform!=Windows&Platform!=Darwin --logger:console;verbosity=$VsTestVerbosity --logger:"trx" --ResultsDirectory:$TestResultsDir" + #mono $VsTestConsole "$TestDir/NuGet.CommandLine.Test.dll" --TestCaseFilter:"Platform!=Windows&Platform!=Darwin" --logger:"console;verbosity=$VsTestVerbosity" --logger:"trx" --ResultsDirectory:"$TestResultsDir" + #MONO_TEST_RESULT=$? + ;; + Darwin) + echo "==================== Run mono tests started at `date -u +"%Y-%m-%dT%H:%M:%S"` ======================" + echo "mono $VsTestConsole $TestDir/NuGet.CommandLine.Test.dll --TestCaseFilter:Platform!=Windows&Platform!=Linux --logger:console;verbosity=$VsTestVerbosity --logger:"trx" --ResultsDirectory:$TestResultsDir" + mono $VsTestConsole "$TestDir/NuGet.CommandLine.Test.dll" --TestCaseFilter:"Platform!=Windows&Platform!=Linux" --logger:"console;verbosity=$VsTestVerbosity" --logger:"trx" --ResultsDirectory:"$TestResultsDir" + MONO_TEST_RESULT=$? + echo "================== mono tests finished started at `date -u +"%Y-%m-%dT%H:%M:%S"` ===================" + echo "" + ;; + *) ;; + esac fi -echo "Core tests finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" +popd -# Func tests -echo "dotnet msbuild build/build.proj /restore:false /target:CoreFuncTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$BUILD_STAGINGDIRECTORY/binlog/04.CoreFuncTests.binlog" -dotnet msbuild build/build.proj /restore:false /target:CoreFuncTests /property:Configuration=Release /property:ReleaseLabel=beta /bl:$BUILD_STAGINGDIRECTORY/binlog/04.CoreFuncTests.binlog +EXITCODE=0 -if [ $? -ne 0 ]; then - RESULTCODE='1' - echo "CoreFuncTests failed!!" +echo "Test Results:" +if [ $UNIT_TEST_RESULT -eq 0 ]; then + echo " Unit tests: Passed" +else + EXITCODE=$UNIT_TEST_RESULT + echo " Unit tests: Failed" fi -if [ -z "$CI" ]; then - popd - exit $RESULTCODE +if [ $FUNC_TEST_RESULT -eq 0 ]; then + echo " Functional tests: Passed" +else + EXITCODE=$FUNC_TEST_RESULT + echo " Functional tests: Failed" fi -#run mono test -TestDir="$DIR/artifacts/NuGet.CommandLine.Test/" -VsTestConsole="$DIR/artifacts/NuGet.CommandLine.Test/vstest/vstest.console.exe" -TestResultsDir="$DIR/build/TestResults" -VsTestVerbosity="minimal" - -if [ "$SYSTEM_DEBUG" == "true" ]; then - VsTestVerbosity="detailed" +if [ $MONO_TEST_RESULT -eq -1 ]; then + echo " Mono tests: Not Run" +elif [ $MONO_TEST_RESULT -eq 0 ]; then + echo " Mono tests: Passed" +else + EXITCODE=$MONO_TEST_RESULT + echo " Mono tests: Failed" fi -#Clean System dll -rm -rf "$TestDir/System.*" "$TestDir/WindowsBase.dll" "$TestDir/Microsoft.CSharp.dll" "$TestDir/Microsoft.Build.Engine.dll" - -#Run xunit test - -case "$(uname -s)" in - Linux) - # We are not testing Mono on linux currently, so comment it out. - #echo "mono $VsTestConsole $TestDir/NuGet.CommandLine.Test.dll --TestCaseFilter:Platform!=Windows&Platform!=Darwin --logger:console;verbosity=$VsTestVerbosity --logger:"trx" --ResultsDirectory:$TestResultsDir" - #mono $VsTestConsole "$TestDir/NuGet.CommandLine.Test.dll" --TestCaseFilter:"Platform!=Windows&Platform!=Darwin" --logger:"console;verbosity=$VsTestVerbosity" --logger:"trx" --ResultsDirectory:"$TestResultsDir" - if [ $RESULTCODE -ne '0' ]; then - RESULTCODE=$? - echo "Unit Tests or Core Func Tests failed on Linux" - exit 1 - fi - ;; - Darwin) - echo "mono $VsTestConsole $TestDir/NuGet.CommandLine.Test.dll --TestCaseFilter:Platform!=Windows&Platform!=Linux --logger:console;verbosity=$VsTestVerbosity --logger:"trx" --ResultsDirectory:$TestResultsDir" - mono $VsTestConsole "$TestDir/NuGet.CommandLine.Test.dll" --TestCaseFilter:"Platform!=Windows&Platform!=Linux" --logger:"console;verbosity=$VsTestVerbosity" --logger:"trx" --ResultsDirectory:"$TestResultsDir" - if [ $? -ne '0' ]; then - RESULTCODE=$? - echo "Mono tests failed!" - exit 1 - fi - ;; - *) ;; -esac - -echo "Func tests finished at `date -u +"%Y-%m-%dT%H:%M:%S"`" - -popd - -exit $RESULTCODE +exit $EXITCODE diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs index d9791a35368..f6006233ed4 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs @@ -10029,13 +10029,7 @@ public async Task RestoreNetCore_WithCustomAliases_WritesConditionWithCorrectAli var project = SimpleTestProjectContext.CreateNETCoreWithSDK( "proj", pathContext.SolutionRoot, - "net5.0-windows"); - - // Workaround: Set all the TFM properties ourselves. - // We can't rely on the SDK setting them, as only .NET 5 SDK P8 and later applies these correctly. - var net50windowsTFM = project.Frameworks.Where(f => f.TargetAlias.Equals("net5.0-windows")).Single(); - net50windowsTFM.Properties.Add("TargetFrameworkMoniker", ".NETCoreApp, Version=v5.0"); - net50windowsTFM.Properties.Add("TargetPlatformMoniker", "Windows, Version=7.0"); + "net7.0-windows"); project.AddPackageToAllFrameworks(packageX); solution.Projects.Add(project); @@ -10054,7 +10048,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( var propsItemGroups = propsXML.Root.Elements().Where(e => e.Name.LocalName == "ItemGroup").ToList(); - Assert.Contains("'$(TargetFramework)' == 'net5.0-windows' AND '$(ExcludeRestorePackageImports)' != 'true'", propsItemGroups[1].Attribute(XName.Get("Condition")).Value.Trim()); + Assert.Contains("'$(TargetFramework)' == 'net7.0-windows' AND '$(ExcludeRestorePackageImports)' != 'true'", propsItemGroups[1].Attribute(XName.Get("Condition")).Value.Trim()); } }