Ok, the solution was in this page :
The type name 'SerialPort' could not be found in the namespace 'System.IO.Ports'
citing this page :
https://www.nuget.org/packages/System.IO.Ports/
In VS code I had to open the terminal (menu View/>Terminal) and write the line
dotnet add package System.IO.Ports --version 9.0.2