private async Task PushSymbols(string packagePath, string source, string apiKey, bool noServiceEndpoint, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, TimeSpan requestTimeout, ILogger log, CancellationToken token) { var isSymbolEndpointSnupkgCapable = symbolPackageUpdateResource != null; // Get the symbol package for this package var symbolPackagePath = GetSymbolsPath(packagePath, isSymbolEndpointSnupkgCapable); // Push the symbols package if it exists if (File.Exists(symbolPackagePath) || symbolPackagePath.IndexOf('*') != -1) { var sourceUri = UriUtility.CreateSourceUri(source); // See if the api key exists if (string.IsNullOrEmpty(apiKey) && !sourceUri.IsFile) { log.LogWarning(string.Format(CultureInfo.CurrentCulture, Strings.Warning_SymbolServerNotConfigured, Path.GetFileName(symbolPackagePath), Strings.DefaultSymbolServer)); } var skipDuplicate = false; await PushPackage(symbolPackagePath, source, apiKey, noServiceEndpoint, skipDuplicate, requestTimeout, log, token, isSnupkgPush : isSymbolEndpointSnupkgCapable); } }
public Task Push( string packagePath, string symbolSource, // empty to not push symbols int timeoutInSecond, bool disableBuffering, Func <string, string> getApiKey, Func <string, string> getSymbolApiKey, bool noServiceEndpoint, bool skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, ILogger log) { return(Push(new[] { packagePath }, symbolSource, timeoutInSecond, disableBuffering, getApiKey, getSymbolApiKey, noServiceEndpoint, skipDuplicate, symbolPackageUpdateResource, log)); }
private async Task PushSymbolsPath(string packagePath, string symbolSource, string apiKey, bool noServiceEndpoint, bool skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, TimeSpan requestTimeout, ILogger log, bool explicitSymbolsPush, CancellationToken token) { bool isSymbolEndpointSnupkgCapable = symbolPackageUpdateResource != null; // Get the symbol package for this package string symbolPackagePath = GetSymbolsPath(packagePath, isSymbolEndpointSnupkgCapable); IEnumerable <string> symbolsToPush = LocalFolderUtility.ResolvePackageFromPath(symbolPackagePath, isSnupkg: isSymbolEndpointSnupkgCapable); bool symbolsPathResolved = symbolsToPush != null && symbolsToPush.Any(); //No files were resolved. if (!symbolsPathResolved) { if (explicitSymbolsPush) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.UnableToFindFile, packagePath)); } } else { Uri symbolSourceUri = UriUtility.CreateSourceUri(symbolSource); // See if the api key exists if (string.IsNullOrEmpty(apiKey) && !symbolSourceUri.IsFile) { log.LogWarning(string.Format(CultureInfo.CurrentCulture, Strings.Warning_SymbolServerNotConfigured, Path.GetFileName(symbolPackagePath), Strings.DefaultSymbolServer)); } foreach (string packageToPush in symbolsToPush) { await PushPackageCore(symbolSource, apiKey, packageToPush, noServiceEndpoint, skipDuplicate, requestTimeout, log, token); } } }
public async Task Push( IList <string> packagePaths, string symbolSource, // empty to not push symbols int timeoutInSecond, bool disableBuffering, Func <string, string> getApiKey, Func <string, string> getSymbolApiKey, bool noServiceEndpoint, bool skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, ILogger log) { // TODO: Figure out how to hook this up with the HTTP request _disableBuffering = disableBuffering; using (var tokenSource = new CancellationTokenSource()) { var requestTimeout = TimeSpan.FromSeconds(timeoutInSecond); tokenSource.CancelAfter(requestTimeout); var apiKey = getApiKey(_source); foreach (var packagePath in packagePaths) { bool explicitSnupkgPush = true; if (!packagePath.EndsWith(NuGetConstants.SnupkgExtension, StringComparison.OrdinalIgnoreCase)) { await PushPackage(packagePath, _source, apiKey, noServiceEndpoint, skipDuplicate, requestTimeout, log, tokenSource.Token); //Since this was not a snupkg push (probably .nupkg), when we try pushing symbols later, don't error if there are no snupkg files found. explicitSnupkgPush = false; } // symbolSource is only set when: // - The user specified it on the command line // - The endpoint for main package supports pushing snupkgs if (!string.IsNullOrEmpty(symbolSource)) { var symbolApiKey = getSymbolApiKey(symbolSource); await PushSymbols(packagePath, symbolSource, symbolApiKey, noServiceEndpoint, skipDuplicate, symbolPackageUpdateResource, requestTimeout, log, explicitSnupkgPush, tokenSource.Token); } } } }
public async Task Push( IList <string> packagePaths, string symbolSource, // empty to not push symbols int timeoutInSecond, bool disableBuffering, Func <string, string> getApiKey, Func <string, string> getSymbolApiKey, bool noServiceEndpoint, bool skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, ILogger log) { // TODO: Figure out how to hook this up with the HTTP request _disableBuffering = disableBuffering; using var tokenSource = new CancellationTokenSource(); var requestTimeout = TimeSpan.FromSeconds(timeoutInSecond); tokenSource.CancelAfter(requestTimeout); var apiKey = getApiKey(_source); foreach (string packagePath in packagePaths) { if (!packagePath.EndsWith(NuGetConstants.SnupkgExtension, StringComparison.OrdinalIgnoreCase)) { // Push nupkgs and possibly the corresponding snupkgs. await PushPackagePath(packagePath, _source, symbolSource, apiKey, getSymbolApiKey, noServiceEndpoint, skipDuplicate, symbolPackageUpdateResource, requestTimeout, log, tokenSource.Token); } else // Explicit snupkg push { // symbolSource is only set when: // - The user specified it on the command line // - The endpoint for main package supports pushing snupkgs if (!string.IsNullOrEmpty(symbolSource)) { string symbolApiKey = getSymbolApiKey(symbolSource); await PushSymbolsPath(packagePath, symbolSource, symbolApiKey, noServiceEndpoint, skipDuplicate, symbolPackageUpdateResource, requestTimeout, log, explicitSymbolsPush : true, tokenSource.Token); } } } }
public async Task Push( string packagePath, string symbolSource, // empty to not push symbols int timeoutInSecond, bool disableBuffering, Func <string, string> getApiKey, Func <string, string> getSymbolApiKey, bool noServiceEndpoint, bool skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, ILogger log) { // TODO: Figure out how to hook this up with the HTTP request _disableBuffering = disableBuffering; using (var tokenSource = new CancellationTokenSource()) { var requestTimeout = TimeSpan.FromSeconds(timeoutInSecond); tokenSource.CancelAfter(requestTimeout); var apiKey = getApiKey(_source); // if only a snupkg is being pushed, then don't try looking for nupkgs. if (!packagePath.EndsWith(NuGetConstants.SnupkgExtension, StringComparison.OrdinalIgnoreCase)) { await PushPackage(packagePath, _source, apiKey, noServiceEndpoint, skipDuplicate , requestTimeout, log, tokenSource.Token, isSnupkgPush : false); } // symbolSource is only set when: // - The user specified it on the command line // - The endpoint for main package supports pushing snupkgs if (!string.IsNullOrEmpty(symbolSource)) { var symbolApiKey = getSymbolApiKey(symbolSource); await PushSymbols(packagePath, symbolSource, symbolApiKey, noServiceEndpoint, symbolPackageUpdateResource, requestTimeout, log, tokenSource.Token); } } }
/// <summary> /// Push nupkgs, and if successful, push any corresponding symbols. /// </summary> /// <exception cref="ArgumentException">Thrown when any resolved file path does not exist.</exception> private async Task PushPackagePath(string packagePath, string source, string symbolSource, // empty to not push symbols string apiKey, Func <string, string> getSymbolApiKey, bool noServiceEndpoint, bool skipDuplicate, SymbolPackageUpdateResourceV3 symbolPackageUpdateResource, TimeSpan requestTimeout, ILogger log, CancellationToken token) { IEnumerable <string> nupkgsToPush = LocalFolderUtility.ResolvePackageFromPath(packagePath, isSnupkg: false); bool alreadyWarnedSymbolServerNotConfigured = false; if (!(nupkgsToPush != null && nupkgsToPush.Any())) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.UnableToFindFile, packagePath)); } Uri packageSourceUri = UriUtility.CreateSourceUri(source); if (string.IsNullOrEmpty(apiKey) && !packageSourceUri.IsFile) { log.LogWarning(string.Format(CultureInfo.CurrentCulture, Strings.NoApiKeyFound, GetSourceDisplayName(source))); } foreach (string nupkgToPush in nupkgsToPush) { bool packageWasPushed = await PushPackageCore(source, apiKey, nupkgToPush, noServiceEndpoint, skipDuplicate, requestTimeout, log, token); // Push corresponding symbols, if successful. if (packageWasPushed && !string.IsNullOrEmpty(symbolSource)) { bool isSymbolEndpointSnupkgCapable = symbolPackageUpdateResource != null; string symbolPackagePath = GetSymbolsPath(nupkgToPush, isSnupkg: isSymbolEndpointSnupkgCapable); // There may not be a snupkg with the same filename. Ignore it since this isn't an explicit snupkg push. if (!File.Exists(symbolPackagePath)) { continue; } if (!alreadyWarnedSymbolServerNotConfigured) { Uri symbolSourceUri = UriUtility.CreateSourceUri(symbolSource); // See if the api key exists if (string.IsNullOrEmpty(apiKey) && !symbolSourceUri.IsFile) { log.LogWarning(string.Format(CultureInfo.CurrentCulture, Strings.Warning_SymbolServerNotConfigured, Path.GetFileName(symbolPackagePath), Strings.DefaultSymbolServer)); alreadyWarnedSymbolServerNotConfigured = true; } } string symbolApiKey = getSymbolApiKey(symbolSource); await PushPackageCore(symbolSource, symbolApiKey, symbolPackagePath, noServiceEndpoint, skipDuplicate, requestTimeout, log, token); } } }