#tool "nuget:?package=NuGet.CommandLine&Version=5.4.0" var target = Argument("target", "Quiet"); var nugetConfigFile = new FilePath(Argument("nugetConfigFile", Context.Environment.GetSpecialPath(SpecialPath.LocalTemp).GetFilePath("NuGet.config").FullPath)); var username = Argument("username", "username"); var apiKey = Argument("apikey", "SECRET"); var feedName = Argument("feedname", "myfeed"); var feedUri = Argument("feeduri", "https://myfeed.com"); Task("Ensure-BlankNugetConfig") .Does(() => { if (FileExists(nugetConfigFile)) { DeleteFile(nugetConfigFile); } var nugetXmlFile = new System.Xml.XmlTextWriter(nugetConfigFile.FullPath, System.Text.Encoding.UTF8); nugetXmlFile.Formatting = System.Xml.Formatting.Indented; nugetXmlFile.WriteStartDocument(); nugetXmlFile.WriteStartElement("configuration"); nugetXmlFile.WriteEndElement(); nugetXmlFile.Flush(); nugetXmlFile.Close(); }); Task("Add-Source") .Does(() => { NuGetAddSource(feedName, feedUri, new NuGetSourcesSettings { ConfigFile = nugetConfigFile, UserName = username, Password = apiKey, Verbosity = NuGetVerbosity.Quiet }); }); Task("Add-ApiKeyToSourceNormal") .Does(() => { NuGetSetApiKey(apiKey, feedUri, new NuGetSetApiKeySettings { ConfigFile = nugetConfigFile, Verbosity = NuGetVerbosity.Normal }); }); Task("Add-ApiKeyToSourceQuiet") .Does(() => { NuGetSetApiKey(apiKey, feedUri, new NuGetSetApiKeySettings { ConfigFile = nugetConfigFile, Verbosity = NuGetVerbosity.Quiet }); }); Task("Normal") .IsDependentOn("Ensure-BlankNugetConfig") .IsDependentOn("Add-Source") .IsDependentOn("Add-ApiKeyToSourceNormal") ; Task("Quiet") .IsDependentOn("Ensure-BlankNugetConfig") .IsDependentOn("Add-Source") .IsDependentOn("Add-ApiKeyToSourceQuiet") ; RunTarget(target);