From 5b1895dd0600b6536410b373d26baa604b88de90 Mon Sep 17 00:00:00 2001 From: Jacek Blaszczynski Date: Wed, 22 Nov 2017 17:00:00 +0100 Subject: [PATCH] Fix all powershell invocations in scripts, CI code and tests to include -NoProfile (#15164) Code execution in several scripts and tests can be affected by powershell profile execution at startup. Adding -NoProfile option to all powershell invocations which may be affected by execution of profile startup code. --- build-test.cmd | 4 ++-- netci.groovy | 8 ++++---- perf.groovy | 8 ++++---- tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.cmd | 2 +- tests/runtest.cmd | 4 ++-- tests/scripts/run-gc-reliability-framework.cmd | 2 +- tests/src/performance/Scenario/JitBench/JitBenchHarness.cs | 6 +++--- tests/src/sizeondisk/sodbench/SoDBench.cs | 6 +++--- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build-test.cmd b/build-test.cmd index 7101ef1..137d6a3 100644 --- a/build-test.cmd +++ b/build-test.cmd @@ -316,9 +316,9 @@ if errorlevel 1 ( REM Prepare the Test Drop REM Cleans any NI from the last run -powershell "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force" +powershell "-NoProfile Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force" REM Cleans up any lock folder used for synchronization from last run -powershell "Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force | where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse" +powershell "-NoProfile Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force | where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse" set CORE_ROOT=%__TestBinDir%\Tests\Core_Root set CORE_ROOT_STAGE=%__TestBinDir%\Tests\Core_Root_Stage diff --git a/netci.groovy b/netci.groovy index d31f74c..9974a9e 100755 --- a/netci.groovy +++ b/netci.groovy @@ -1533,7 +1533,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR // Zip up the tests directory so that we don't use so much space/time copying // 10s of thousands of files around. - buildCommands += "powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}', '.\\bin\\tests\\tests.zip')\""; + buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${arch}.${configuration}', '.\\bin\\tests\\tests.zip')\""; if (!isJitStressScenario(scenario)) { // For windows, pull full test results and test drops for x86/x64. @@ -1589,7 +1589,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR // Zip up the tests directory so that we don't use so much space/time copying // 10s of thousands of files around. - buildCommands += "powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${buildArchitecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; + buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${buildArchitecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; // Add archival. Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip", "bin/Product/**/.nuget/**") @@ -1617,7 +1617,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR // Zip up the tests directory so that we don't use so much space/time copying // 10s of thousands of files around. - buildCommands += "powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${architecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; + buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${architecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; // Add archival. Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip", "bin/Product/**/.nuget/**") @@ -2427,7 +2427,7 @@ Constants.allScenarios.each { scenario -> else { // windowsArmJob == true // Unzip tests. - batchFile("powershell -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('bin\\tests\\tests.zip', 'bin\\tests\\${osGroup}.${architecture}.${configuration}')") + batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('bin\\tests\\tests.zip', 'bin\\tests\\${osGroup}.${architecture}.${configuration}')") // Build the build commands def buildCommands = "" diff --git a/perf.groovy b/perf.groovy index dede228..a87bf83 100644 --- a/perf.groovy +++ b/perf.groovy @@ -64,7 +64,7 @@ def static getOSGroup(def os) { steps { // Batch - batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") + batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"") batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion") //Do this here to remove the origin but at the front of the branch name as this is a problem for BenchView @@ -566,7 +566,7 @@ parallel( steps { // Batch - batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") + batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"") batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion") @@ -665,7 +665,7 @@ parallel( steps { // Install nuget and get BenchView tools - batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") + batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"") batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion") @@ -759,7 +759,7 @@ parallel( steps { // Batch - batchFile("powershell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") + batchFile("powershell -NoProfile wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile \"%WORKSPACE%\\nuget.exe\"") batchFile("if exist \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\" rmdir /s /q \"%WORKSPACE%\\Microsoft.BenchView.JSONFormat\"") batchFile("\"%WORKSPACE%\\nuget.exe\" install Microsoft.BenchView.JSONFormat -Source http://benchviewtestfeed.azurewebsites.net/nuget -OutputDirectory \"%WORKSPACE%\" -Prerelease -ExcludeVersion") diff --git a/tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.cmd b/tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.cmd index 635df95..471637b 100644 --- a/tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.cmd +++ b/tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.cmd @@ -33,7 +33,7 @@ if exist %__ConfigFileName% ( ) :: powershell "Get-Content %__TemplateFileName% -replace (""##Insert_Runtime_Root##"", ""%__RuntimeRoot%"") | Output-File %__ConfigFileName% " -powershell "(Get-Content \"%__TemplateFileName%\")`"^ +powershell "-NoProfile (Get-Content \"%__TemplateFileName%\")`"^ "-replace \"##Insert_Runtime_Root##\", \"%__RuntimeRoot%\" `"^ "|ForEach-Object{$_ -replace \"##Insert_Nuget_Cache_Root##\", \"%__NugetCacheDir%\"} `"^ "|ForEach-Object{$_ -replace \"##Cli_Path##\", \"%__CliPath%\"} `"^ diff --git a/tests/runtest.cmd b/tests/runtest.cmd index 2ddda53..2db98b9 100644 --- a/tests/runtest.cmd +++ b/tests/runtest.cmd @@ -190,9 +190,9 @@ if defined DoLink ( REM Prepare the Test Drop REM Cleans any NI from the last run -powershell "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force" +powershell "-NoProfile Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force" REM Cleans up any lock folder used for synchronization from last run -powershell "Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force | where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse" +powershell "-NoProfile Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force | where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse" if defined CORE_ROOT goto SkipCoreRootSetup diff --git a/tests/scripts/run-gc-reliability-framework.cmd b/tests/scripts/run-gc-reliability-framework.cmd index 66be1d6..bb7bee1 100644 --- a/tests/scripts/run-gc-reliability-framework.cmd +++ b/tests/scripts/run-gc-reliability-framework.cmd @@ -6,7 +6,7 @@ set CORE_ROOT=%CD%\bin\tests\Windows_NT.%1.%2\Tests\Core_Root set FRAMEWORK_DIR=%CD%\bin\tests\Windows_NT.%1.%2\GC\Stress\Framework\ReliabilityFramework -powershell "%CORE_ROOT%\CoreRun.exe %FRAMEWORK_DIR%\ReliabilityFramework.exe %FRAMEWORK_DIR%\testmix_gc.config" +powershell "-NoProfile %CORE_ROOT%\CoreRun.exe %FRAMEWORK_DIR%\ReliabilityFramework.exe %FRAMEWORK_DIR%\testmix_gc.config" if %ERRORLEVEL% == 100 ( @rem The ReliabilityFramework returns 100 on success and 99 on failure echo ReliabilityFramework successful diff --git a/tests/src/performance/Scenario/JitBench/JitBenchHarness.cs b/tests/src/performance/Scenario/JitBench/JitBenchHarness.cs index 0ab9ff8..6da3b52 100644 --- a/tests/src/performance/Scenario/JitBench/JitBenchHarness.cs +++ b/tests/src/performance/Scenario/JitBench/JitBenchHarness.cs @@ -164,7 +164,7 @@ namespace JitBench { WorkingDirectory = s_jitBenchDevDirectory, FileName = @"powershell.exe", - Arguments = $".\\Dotnet-Install.ps1 -SharedRuntime -InstallDir .dotnet -Channel master -Architecture {s_targetArchitecture}" + Arguments = $"-NoProfile .\\Dotnet-Install.ps1 -SharedRuntime -InstallDir .dotnet -Channel master -Architecture {s_targetArchitecture}" }; LaunchProcess(psi, 180000); } @@ -175,7 +175,7 @@ namespace JitBench { WorkingDirectory = s_jitBenchDevDirectory, FileName = @"powershell.exe", - Arguments = $".\\Dotnet-Install.ps1 -InstallDir .dotnet -Channel master -Architecture {s_targetArchitecture}" + Arguments = $"-NoProfile .\\Dotnet-Install.ps1 -InstallDir .dotnet -Channel master -Architecture {s_targetArchitecture}" }; LaunchProcess(psi, 180000); @@ -234,7 +234,7 @@ namespace JitBench { WorkingDirectory = s_jitBenchDevDirectory, FileName = "powershell.exe", - Arguments = $"-Command \".\\AspNet-GenerateStore.ps1 -InstallDir .store -Architecture {s_targetArchitecture} -Runtime win7-{s_targetArchitecture}; gi env:JITBENCH_*, env:DOTNET_SHARED_STORE | %{{ \\\"$($_.Name)=$($_.Value)\\\" }} 1>>{EnvironmentFileName}\"" + Arguments = $"-NoProfile -Command \".\\AspNet-GenerateStore.ps1 -InstallDir .store -Architecture {s_targetArchitecture} -Runtime win7-{s_targetArchitecture}; gi env:JITBENCH_*, env:DOTNET_SHARED_STORE | %{{ \\\"$($_.Name)=$($_.Value)\\\" }} 1>>{EnvironmentFileName}\"" }; LaunchProcess(psi, 1800000, environment); diff --git a/tests/src/sizeondisk/sodbench/SoDBench.cs b/tests/src/sizeondisk/sodbench/SoDBench.cs index ac544ab..4c311ad 100644 --- a/tests/src/sizeondisk/sodbench/SoDBench.cs +++ b/tests/src/sizeondisk/sodbench/SoDBench.cs @@ -416,7 +416,7 @@ namespace SoDBench var psi = new ProcessStartInfo() { WorkingDirectory = s_sandboxDir.FullName, FileName = @"powershell.exe", - Arguments = $"wget https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1 -OutFile Dotnet-Install.ps1" + Arguments = $"-NoProfile wget https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1 -OutFile Dotnet-Install.ps1" }; LaunchProcess(psi, 180000); } @@ -426,7 +426,7 @@ namespace SoDBench var psi = new ProcessStartInfo() { WorkingDirectory = s_sandboxDir.FullName, FileName = @"powershell.exe", - Arguments = $".\\Dotnet-Install.ps1 -SharedRuntime -InstallDir .dotnet -Channel {s_dotnetChannel} -Architecture {s_targetArchitecture}" + Arguments = $"-NoProfile .\\Dotnet-Install.ps1 -SharedRuntime -InstallDir .dotnet -Channel {s_dotnetChannel} -Architecture {s_targetArchitecture}" }; LaunchProcess(psi, 180000); } @@ -436,7 +436,7 @@ namespace SoDBench var psi = new ProcessStartInfo() { WorkingDirectory = s_sandboxDir.FullName, FileName = @"powershell.exe", - Arguments = $".\\Dotnet-Install.ps1 -InstallDir .dotnet -Channel {s_dotnetChannel} -Architecture {s_targetArchitecture}" + Arguments = $"-NoProfile .\\Dotnet-Install.ps1 -InstallDir .dotnet -Channel {s_dotnetChannel} -Architecture {s_targetArchitecture}" }; LaunchProcess(psi, 180000); } -- 2.7.4