| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
scriptcs integrates tightly with NuGet packages. This page describes how to install and use NuGet packages with scriptcs.
You can install packages directly from the scriptcs CLI. This will pull the relevant packages from NuGet, and install them in the scriptcs_packages folder.
Once the packages are installed, you can simply start using them in your script code directly (just import the namespaces - no additional bootstraping or DLL referencing is needed).
The install command will also create a scriptcs_packages.config file if you don't have one - so that you can easily redistribute your script (without having to copy the package binaries).
scriptcs -install {package name} will install the desired package from NuGet.
For example:
scriptcs -install ServiceStack
scriptcs -install {package name} {version} will install a specific version of the package
if you want to install any prerelease packages, you have to include -pre switch
For example:
scriptcs -install ScriptCs.Metrics 0.8.0.1-beta -pre
scriptcs -install (without package name) will look for the scriptcs_packages.config file located in the current execution directory, and install all the packages specified there. You only need to specify top level packages.
For example, you might create the following scriptcs_packages.config:
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Nancy.Hosting.Self" version="0.16.1" targetFramework="net40" /> <package id="Nancy.Bootstrappers.Autofac" version="0.16.1" targetFramework="net40" /> <package id="Autofac" version="2.6.3.862" targetFramework="net40" /> </packages>
And then just call:
scriptcs -install
As a result, all packages specified in the scriptcs_packages.config, including all dependencies, will be downloaded and installed in the scriptcs_packages folder.
At this point, you might ask which package feeds will scriptcs -install use?
We rely on the regular NuGet.config convention. Here's the order of precedence when locating this file:
Local NuGet.config in the script folder. This is especially useful if, for a given script app, you want to pull something from private feed or if you are testing local packages from your own hard disk.
Main NuGet.config from %APPDATA%\NuGet\. If you use Visual Studio, this is the same file that VS Package Manager uses, so if you have pre-configured any feeds there, scriptcs will actually pick them up.
If there is no NuGet.config at your machine (i.e. you've never used nuget.exe), we'll default to official Nuget package source
Because of that, scriptcs will also use your local NuGet cache.
Having scriptcs_packages.config makes redistributing your script easy, as you only have to copy CSX files and scriptcs_packages.config, without worrying about moving the DLLs too. You can generate a package.config file based on the contents of your scriptcs_packages folder by calling:
scriptcs -save
This is really handy when you installed packages using nuget.exe, or copied them from another project and have no scriptcs_packages.config for your script application.
Now when you move your script to a different machine/client you can just run install again - against the scriptcs_packages.config file.
| Back | FazBrowse Home | New Git URL |