'Configure vs code for Selenium 4 - error while installing dotnet 6 sdk using PowerShell

I was following the steps here:

https://www.fleekitsolutions.com/use-selenium-c-visual-studio-code/

To use Selenium 4 with vs code. Then this led me to the following instructions here:

https://docs.microsoft.com/en-us/dotnet/core/install/windows?tabs=net60#install-with-powershell-automation

to install .NET 6 SDK using PowerShell script, and I got the error below:

dotnet-install.ps1: Exception calling "ExtractToFile" with "3" argument(s): "The archive entry was compressed using an unsupported compression method.

See the snapshot below.

My intention was to get the latest version of "Visual C++ Redistributable for Visual Studio" which led me to the above instructions to install dotnet 6 sdk.

Note the I am using elevated admin PowerShell console for this purpose.

I also got a similar error when I was trying to install the latest version of Selenium PowerShell Module using PowerShell. When I installed version 3.0.1 of Selenium-PowerShell module, it was successful.

Edit: After installing .NET SDK 6 from MS Build Tools, I completed the steps to configure vscode for Selenium 4, and now I am getting this error:

PS> dotnet restore

C:\Projects\Selenium\demoProject\FirstTest\FirstTest.csproj : error NU1100: Unable to resolve 'Selenium.WebDriver (>= 4.1.0)' for 'net6.0'.

Other things I tried:

I tried the following config in .csproj and nothing worked:

<TargetFramework>net48</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

Note that the sample Hello World Program of dotnet new console is working fine with all the TargetFramework I used above. The error occurs when I add Selenium.WebDriver to the project using NuGet package manager extension.

After I add the Selenium WebDriver, I get popup requesting to restore, and OmniSharp server will restart, and then a similar error shows up in the output:

[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Projects\Selenium\demoProject\FirsProj\FirsProj.csproj'.
c:\Projects\Selenium\demoProject\FirsProj\FirsProj.csproj
c:\Projects\Selenium\demoProject\FirsProj\FirsProj.csproj(0,0): Error: Unable to resolve 'Selenium.WebDriver (>= 4.1.0)' for '.NETFramework,Version=v4.8'.
c:\Projects\Selenium\demoProject\FirsProj\FirsProj.csproj(0,0): Error: Unable to resolve 'Selenium.WebDriver (>= 4.1.0)' for '.NETFramework,Version=v4.8/win7-x86'.

[info]: OmniSharp.MSBuild.ProjectManager
        Update project: FirsProj
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
        FirsProj: Did not find 'Selenium.WebDriver' in lock file.

I appreciate your help.

enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source