I want to install phantomJS nuget package for my .NET Core project. This nuget package contains an .exe file (phantomjs.exe). (C:\Users\.nuget\packages\PhantomJS\2.1.1\tools\phantomjs)
Building or publishing solution doesn't copy .exe file inside the bin or publish folder.
Do I have to add a specific configuration in my project.json to automatically copy .exe when I'll publish or build??
The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.
For . NET (including . NET Core), the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for . NET are created, hosted, and consumed, and provides the tools for each of those roles.
Open your file, and inside packageSources add a new local key following this structure <add key="local" value="path" /> . This path can be a relative or absolute from NuGet. config folder. Now you can install a package locally with dotnet add package and source option to local.
Currently PhantomJS nuget package (v.2.1.1) targets classic windows-only .NET projects; phantomjs.exe is included into 'tools' folder and on install nuget executes script (install.ps1) that adds 'phantomjs.exe' to the project with CopyToOutputDirectory=true option. Unfortunately install scripts are not supported for netcore projects; since PhantomJS nuget package doesn't include any managed assemblies, it can be installed for netcore project but 'tools' folder is ignored.
It is possible to use "script" section in project.json ("postcompile"/"postpublish" mentioned by @Pawel) to copy phantomjs.exe explicitly, but it seems there are no any acceptable way to resolve path to PhantomJS nuget package during build procedure. In any way, PhantomJS nuget package includes only windows PhantomJS build and it is useless if you planning to run your .NET Core project under Linux or OS-X.
Maybe it is better avoid using PhantomJS nuget for netcore projects at all, and create custom build script (executed with "postcompile") that downloads and extracts appropriate phantomjs build for your target runtime platform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With