Using packages in the .cs source file without IDE

Here is a thing. I have a simple .cs source file and I compile everything with csc.exe using command line.

using System; 

class HelloWorld {
static void Main(string[] args) 
    { 

       Console.WriteLine("Hello World.");
    }
}

I would like to use PhantomJS https://www.nuget.org/packages/PhantomJS/ inside that source file. How can I do that?

Are there ways to link and use packages from .cs source file and what exact steps should be taken?

You should download the nuget package, unzip if needed, then for csc.exe you need the -reference command line option for the phantomjs DLL.

I think I was successful in referencing Selenium WebDriver package: https://www.nuget.org/packages/Selenium.WebDriver/3.141.0

However PhantomJS package base seems to be an .exe file and not .dll https://www.nuget.org/packages/PhantomJS/

When I tried referencing the .exe file of PhantomJS this is the output:

Microsoft (R) Visual C# Compiler version 4.8.3752.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

fatal error CS0009: Metadata file 'c:\Users\vaida\Desktop\PhantomJS\phantomjs.exe' could not be opened -- 'An attempt was made to load a program with an incorrect format. '

This is what I’m trying to achieve: reference using csc.exe and create a simple working example that uses selenium and phantomjs

.NET Foundation Website | Blog | Projects | Code of Conduct