@@ -976,12 +976,11 @@ Microsoft.NETCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.Ap
976976 TestAutobuilderScript ( autobuilder , 0 , 9 ) ;
977977 }
978978
979- [ Fact ]
980- public void TestDotnetVersionWindows ( )
979+ private void TestDotnetVersionWindows ( Action action , int commandsRun )
981980 {
982981 actions . RunProcess [ "cmd.exe /C dotnet --list-sdks" ] = 0 ;
983982 actions . RunProcessOut [ "cmd.exe /C dotnet --list-sdks" ] = "2.1.3 [C:\\ Program Files\\ dotnet\\ sdks]\n 2.1.4 [C:\\ Program Files\\ dotnet\\ sdks]" ;
984- actions . RunProcess [ @"cmd.exe /C pwsh -NoProfile -ExecutionPolicy unrestricted -Command ""[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.3 -InstallDir C:\Project\.dotnet""" ] = 0 ;
983+ action ( ) ;
985984 actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet --info" ] = 0 ;
986985 actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet clean C:\Project\test.csproj" ] = 0 ;
987986 actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet restore C:\Project\test.csproj" ] = 0 ;
@@ -1004,39 +1003,28 @@ public void TestDotnetVersionWindows()
10041003 actions . LoadXml [ @"C:\Project\test.csproj" ] = xml ;
10051004
10061005 var autobuilder = CreateAutoBuilder ( true , dotnetVersion : "2.1.3" ) ;
1007- TestAutobuilderScript ( autobuilder , 0 , 6 ) ;
1006+ TestAutobuilderScript ( autobuilder , 0 , commandsRun ) ;
10081007 }
10091008
10101009 [ Fact ]
1011- public void TestDotnetVersionWindowsNoPwsh ( )
1010+ public void TestDotnetVersionWindowsWithPwsh ( )
10121011 {
1013- actions . RunProcess [ "cmd.exe /C dotnet --list-sdks" ] = 0 ;
1014- actions . RunProcessOut [ "cmd.exe /C dotnet --list-sdks" ] = "2.1.3 [C:\\ Program Files\\ dotnet\\ sdks]\n 2.1.4 [C:\\ Program Files\\ dotnet\\ sdks]" ;
1015- actions . RunProcess [ @"cmd.exe /C pwsh -NoProfile -ExecutionPolicy unrestricted -Command ""[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.3 -InstallDir C:\Project\.dotnet""" ] = 1 ;
1016- actions . RunProcess [ @"cmd.exe /C powershell -NoProfile -ExecutionPolicy unrestricted -Command ""[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.3 -InstallDir C:\Project\.dotnet""" ] = 0 ;
1017- actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet --info" ] = 0 ;
1018- actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet clean C:\Project\test.csproj" ] = 0 ;
1019- actions . RunProcess [ @"cmd.exe /C C:\Project\.dotnet\dotnet restore C:\Project\test.csproj" ] = 0 ;
1020- actions . RunProcess [ @"cmd.exe /C C:\odasa\tools\odasa index --auto C:\Project\.dotnet\dotnet build --no-incremental C:\Project\test.csproj" ] = 0 ;
1021- actions . FileExists [ "csharp.log" ] = true ;
1022- actions . FileExists [ @"C:\Project\test.csproj" ] = true ;
1023- actions . GetEnvironmentVariable [ "CODEQL_EXTRACTOR_CSHARP_TRAP_DIR" ] = "" ;
1024- actions . GetEnvironmentVariable [ "CODEQL_EXTRACTOR_CSHARP_SOURCE_ARCHIVE_DIR" ] = "" ;
1025- actions . GetEnvironmentVariable [ "PATH" ] = "/bin:/usr/bin" ;
1026- actions . EnumerateFiles [ @"C:\Project" ] = "foo.cs\n test.cs\n test.csproj" ;
1027- actions . EnumerateDirectories [ @"C:\Project" ] = "" ;
1028- var xml = new XmlDocument ( ) ;
1029- xml . LoadXml ( @"<Project Sdk=""Microsoft.NET.Sdk"">
1030- <PropertyGroup>
1031- <OutputType>Exe</OutputType>
1032- <TargetFramework>netcoreapp2.1</TargetFramework>
1033- </PropertyGroup>
1034-
1035- </Project>" ) ;
1036- actions . LoadXml [ @"C:\Project\test.csproj" ] = xml ;
1012+ TestDotnetVersionWindows ( ( ) =>
1013+ {
1014+ actions . RunProcess [ @"cmd.exe /C pwsh -NoProfile -ExecutionPolicy unrestricted -Command ""[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.3 -InstallDir C:\Project\.dotnet""" ] = 0 ;
1015+ } ,
1016+ 6 ) ;
1017+ }
10371018
1038- var autobuilder = CreateAutoBuilder ( true , dotnetVersion : "2.1.3" ) ;
1039- TestAutobuilderScript ( autobuilder , 0 , 7 ) ;
1019+ [ Fact ]
1020+ public void TestDotnetVersionWindowsWithoutPwsh ( )
1021+ {
1022+ TestDotnetVersionWindows ( ( ) =>
1023+ {
1024+ actions . RunProcess [ @"cmd.exe /C pwsh -NoProfile -ExecutionPolicy unrestricted -Command ""[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.3 -InstallDir C:\Project\.dotnet""" ] = 1 ;
1025+ actions . RunProcess [ @"cmd.exe /C powershell -NoProfile -ExecutionPolicy unrestricted -Command ""[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.3 -InstallDir C:\Project\.dotnet""" ] = 0 ;
1026+ } ,
1027+ 7 ) ;
10401028 }
10411029
10421030 [ Fact ]
0 commit comments