C# Класс NugetForUnity.NugetHelper

Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
NugetConfigFilePath string
PackOutputDirectory string

Открытые методы

Метод Описание
DownloadImage ( string url ) : Texture2D

Downloads an image at the given URL and converts it to a Unity Texture2D.

GetInstalledPackages ( ) : List

Gets the list of packages that are actually installed in the project.

GetUpdates ( List packagesToUpdate, bool includePrerelease = false, bool includeAllVersions = false, string targetFrameworks = "", string versionContraints = "" ) : List

Queries the server with the given list of installed packages to get any updates that are available.

Install ( NugetPackage package, bool refreshAssets = true ) : void

Installs the given package.

LoadNugetConfigFile ( ) : void

Loads the NuGet.config file.

LogVerbose ( string format ) : void

Outputs the given message to the log only if verbose mode is active. Otherwise it does nothing.

Pack ( string nuspecFilePath ) : void

Calls "nuget.exe pack" to create a .nupkg file based on the given .nuspec file.

Push ( NuspecFile nuspec, string nuspecFilePath, string apiKey = "" ) : void

Calls "nuget.exe push" to push a .nupkf file to the the server location defined in the NuGet.config file. Note: This differs slightly from NuGet's Push command by automatically calling Pack if the .nupkg doesn't already exist.

Restore ( ) : void

Restores all packages defined in packages.config.

Search ( string searchTerm = "", bool includeAllVersions = false, bool includePrerelease = false, int numberToGet = 15, int numberToSkip ) : List

Gets a list of NuGetPackages via the HTTP Search() function defined by NuGet.Server and NuGet Gallery. This allows searching for partial IDs or even the empty string (the default) to list ALL packages. NOTE: See the functions and parameters defined here: https://www.nuget.org/api/v2/$metadata

Uninstall ( NugetPackageIdentifier package, bool refreshAssets = true ) : void

"Uninstalls" the given package by simply deleting its folder.

Update ( NugetPackageIdentifier currentVersion, NugetPackage newVersion, bool refreshAssets = true ) : void

Updates a package by uninstalling the currently installed version and installing the "new" version.

UpdateAll ( IEnumerable updates, List packagesToUpdate ) : void

Installs all of the given updates, and uninstalls the corresponding package that is already installed.

Приватные методы

Метод Описание
Clean ( NugetPackageIdentifier package ) : void

Cleans up a package after it has been installed. Since we are in Unity, we can make certain assumptions on which files will NOT be used, so we can delete them.

CopyStream ( Stream input, Stream output ) : void

Copies the contents of input to output. Doesn't close either stream.

DeleteAllFiles ( string directoryPath, string extension ) : void

Deletes all files in the given directory or in any sub-directory, with the given extension.

DeleteDirectory ( string directoryPath ) : void

Recursively deletes the folder at the given path. NOTE: Directory.Delete() doesn't delete Read-Only files, whereas this does.

DeleteFile ( string filePath ) : void

Deletes a file at the given filepath.

FixSpaces ( string directoryPath ) : void

Replace all %20 encodings with a normal space.

GetCachedPackage ( NugetPackageIdentifier packageId ) : NugetPackage

Tries to find an already cached package that matches (or is in the range of) the given package ID.

GetInstalledPackage ( NugetPackageIdentifier packageId ) : NugetPackage

Tries to find an already installed package that matches (or is in the range of) the given package ID.

GetOnlinePackage ( NugetPackageIdentifier packageId ) : NugetPackage

Tries to find an "online" (in the package sources - which could be local) package that matches (or is in the range of) the given package ID.

GetSpecificPackage ( NugetPackageIdentifier packageId ) : NugetPackage

Gets a NugetPackage from the NuGet server with the exact ID and Version given. If an exact match isn't found, it selects the next closest version available.

InstallIdentifier ( NugetPackageIdentifier package ) : void

Installs the package given by the identifer. It fetches the appropriate full package from the installed packages, package cache, or package sources and installs it.

IsInstalled ( NugetPackageIdentifier package ) : bool

Checks if a given package is installed.

NugetHelper ( ) : System

Static constructor used by Unity to initialize NuGet and restore packages defined in packages.config.

RunNugetProcess ( string arguments, bool logOuput = true ) : void

Runs nuget.exe using the given arguments.

Описание методов

DownloadImage() публичный статический Метод

Downloads an image at the given URL and converts it to a Unity Texture2D.
public static DownloadImage ( string url ) : Texture2D
url string The URL of the image to download.
Результат UnityEngine.Texture2D

GetInstalledPackages() публичный статический Метод

Gets the list of packages that are actually installed in the project.
public static GetInstalledPackages ( ) : List
Результат List

GetUpdates() публичный статический Метод

Queries the server with the given list of installed packages to get any updates that are available.
public static GetUpdates ( List packagesToUpdate, bool includePrerelease = false, bool includeAllVersions = false, string targetFrameworks = "", string versionContraints = "" ) : List
packagesToUpdate List The list of currently installed packages.
includePrerelease bool True to include prerelease packages (alpha, beta, etc).
includeAllVersions bool True to include older versions that are not the latest version.
targetFrameworks string The specific frameworks to target?
versionContraints string The version constraints?
Результат List

Install() публичный статический Метод

Installs the given package.
public static Install ( NugetPackage package, bool refreshAssets = true ) : void
package NugetPackage The package to install.
refreshAssets bool True to refresh the Unity asset database. False to ignore the changes (temporarily).
Результат void

LoadNugetConfigFile() публичный статический Метод

Loads the NuGet.config file.
public static LoadNugetConfigFile ( ) : void
Результат void

LogVerbose() публичный статический Метод

Outputs the given message to the log only if verbose mode is active. Otherwise it does nothing.
public static LogVerbose ( string format ) : void
format string The formatted message string.
Результат void

Pack() публичный статический Метод

Calls "nuget.exe pack" to create a .nupkg file based on the given .nuspec file.
public static Pack ( string nuspecFilePath ) : void
nuspecFilePath string The full filepath to the .nuspec file to use.
Результат void

Push() публичный статический Метод

Calls "nuget.exe push" to push a .nupkf file to the the server location defined in the NuGet.config file. Note: This differs slightly from NuGet's Push command by automatically calling Pack if the .nupkg doesn't already exist.
public static Push ( NuspecFile nuspec, string nuspecFilePath, string apiKey = "" ) : void
nuspec NuspecFile The NuspecFile which defines the package to push. Only the ID and Version are used.
nuspecFilePath string The full filepath to the .nuspec file to use. This is required by NuGet's Push command.
apiKey string The API key to use when pushing a package to the server. This is optional.
Результат void

Restore() публичный статический Метод

Restores all packages defined in packages.config.
public static Restore ( ) : void
Результат void

Search() публичный статический Метод

Gets a list of NuGetPackages via the HTTP Search() function defined by NuGet.Server and NuGet Gallery. This allows searching for partial IDs or even the empty string (the default) to list ALL packages. NOTE: See the functions and parameters defined here: https://www.nuget.org/api/v2/$metadata
public static Search ( string searchTerm = "", bool includeAllVersions = false, bool includePrerelease = false, int numberToGet = 15, int numberToSkip ) : List
searchTerm string The search term to use to filter packages. Defaults to the empty string.
includeAllVersions bool True to include older versions that are not the latest version.
includePrerelease bool True to include prerelease packages (alpha, beta, etc).
numberToGet int The number of packages to fetch.
numberToSkip int The number of packages to skip before fetching.
Результат List

Uninstall() публичный статический Метод

"Uninstalls" the given package by simply deleting its folder.
public static Uninstall ( NugetPackageIdentifier package, bool refreshAssets = true ) : void
package NugetPackageIdentifier The NugetPackage to uninstall.
refreshAssets bool True to force Unity to refesh its Assets folder. False to temporarily ignore the change. Defaults to true.
Результат void

Update() публичный статический Метод

Updates a package by uninstalling the currently installed version and installing the "new" version.
public static Update ( NugetPackageIdentifier currentVersion, NugetPackage newVersion, bool refreshAssets = true ) : void
currentVersion NugetPackageIdentifier The current package to uninstall.
newVersion NugetPackage The package to install.
refreshAssets bool True to refresh the assets inside Unity. False to ignore them (for now). Defaults to true.
Результат void

UpdateAll() публичный статический Метод

Installs all of the given updates, and uninstalls the corresponding package that is already installed.
public static UpdateAll ( IEnumerable updates, List packagesToUpdate ) : void
updates IEnumerable The list of all updates to install.
packagesToUpdate List The list of all packages currently installed.
Результат void

Описание свойств

NugetConfigFilePath публичное статическое свойство

The path to the nuget.config file.
public static string NugetConfigFilePath
Результат string

PackOutputDirectory публичное статическое свойство

The path where to put created (packed) and downloaded (not installed yet) .nupkg files.
public static string PackOutputDirectory
Результат string