NuGetAliases.

NuGetHasSource(ICakeContext, string, NuGetSourcesSettings) Method

Summary

Checks whether or not a NuGet package source exists in the global user configuration, using the specified source and settings.
Namespace
Cake.Common.Tools.NuGet
Containing Type
NuGetAliases

Syntax

[CakeMethodAlias]
[CakeAliasCategory("HasSource")]
[CakeNamespaceImport("Cake.Common.Tools.NuGet.Sources")]
public static bool NuGetHasSource(this ICakeContext context, string source, NuGetSourcesSettings settings)

Examples

var nugetSourceSettings = new NuGetSourcesSettings
{
    UserName = EnvironmentVariable("PRIVATE_FEED_USERNAME"),
    Password = EnvironmentVariable("PRIVATE_FEED_PASSWORD"),
    IsSensitiveSource = true,
    Verbosity = NuGetVerbosity.Detailed
};
var feed = new
{
    Name = EnvironmentVariable("PRIVATE_FEED_NAME"),
    Source = EnvironmentVariable("PRIVATE_FEED_SOURCE")
};
if (!NuGetHasSource(
    source:feed.Source,
    settings:nugetSourceSettings))
{
    Information("Source missing");
}
else
{
    Information("Source already exists");
}

Attributes

Type Description
CakeMethodAliasAttribute An attribute used to mark script method aliases.
CakeAliasCategoryAttribute An attribute used for documentation of alias methods/properties.
CakeNamespaceImportAttribute An attribute used to hint Cake about additional namespaces that need to be imported for an alias to work. This attribute can mark an extension method, the extension method class, or the assembly to provide a global set of imports

Parameters

Name Type Description
context ICakeContext The context.
source string Path to the package(s) source.
settings NuGetSourcesSettings The settings.

Return Value

Type Description
bool Whether the specified NuGet package source exist.