SeleniumHQ / seleniumhq.github.io

Official Selenium website and documentation
https://selenium.dev
Apache License 2.0
1.11k stars 1.3k forks source link

When adding Selenium.WebDriver to C# project using VSCode, the project doesn't compile #952

Closed tarekahf closed 2 years ago

tarekahf commented 2 years ago

What happened?

I was following the steps here:

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

To use Selenium 4 with vs code. I installed .NET 5 and .NET 6 SDK.

I created the sample Hello World Project using dotnet new console and tried to import the Selenium.WebDriver package using NuGet, and run dotnet restore, I get the following error:

error NU1100: Unable to resolve 'Selenium.WebDriver (>= 4.1.0)' for 'net6.0'.

vscode CS Selenium error

What browsers and operating systems are you seeing the problem on?

How can we reproduce the issue?

- Open vscode
- Switch to .NET 5 to verify or use .NET 6 (the default and latest one installed)
`dotnet new globaljson --sdk-version 5.0.405 --force`
- Create sample dotnet project using `dotnet new console`
- Run the project ==> is is good
- Import Selnium.WebDriver using NuGet Add Package (Ctrl-Shift-P)
- Run `dotnet restore` you will get this error:
`error NU1100: Unable to resolve 'Selenium.WebDriver (>= 4.1.0)' for 'net6.0'`

Relevant log output

The OmniSharp server output will display the following:

[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.

Operating System

Windows 10 Enterprise

Selenium version

C# with .NET 6 and VSCode

What are the browser(s) and version(s) where you see this issue?

98.0.4758.82

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 98.0.4758.82

Are you using Selenium Grid?

N/A

diemol commented 2 years ago

Duplicate of https://github.com/SeleniumHQ/selenium/issues/10354

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.