internal static async Task PushPackageAsync(PushOption options, ILogger logger, Stream packageStream) { packageStream.Seek(0, SeekOrigin.Begin); using (logger.BeginScope("Publishing")) { try { var token = await GetTokenAsync(options, logger); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", options.DotykMeToken); using (var fileStream = new FileStream(options.PackagePath, FileMode.Open)) { var streamContent = new StreamContent(fileStream); var resoponse = await client.PostAsync($"{options.ServerUrl}/api/Application/Publish", streamContent); if (resoponse.IsSuccessStatusCode) { } } // client.PostAsync("/api/Application/Publish", ); // try // { // logger.LogInformation("Uploading package\r\n" + // "Package: {package}\r\n" + // "Feed: {feed}\r\n" + // "Server: {server}", options.PackagePath, options.Feed, options.ServerUrl); // await client.SubmitPackage(packageStream, options.Feed); // logger.LogInformation("Package published"); // } // catch (Exception ex) // { // logger.LogError(new EventId(), ex, "Failed to publish package"); // throw; // } } catch (Exception ex) { logger.LogError(ex.Message); throw; } } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private async void Execute(object sender, EventArgs e) { await this.package.JoinableTaskFactory.SwitchToMainThreadAsync(); DTE2 dte = await this.ServiceProvider.GetServiceAsync(typeof(DTE)) as DTE2; ToolWindowPane pane = this.package.FindToolWindow(typeof(WDotykCmd), 0, true); WDotykCmdControl wDotyk = pane.Content as WDotykCmdControl; if (dte.Solution.Count != 0) if (dte.Solution.Projects.Count != 0) { if (!string.IsNullOrEmpty(wDotyk.PushPackage.Text)) { PushOption pushOption = new PushOption() { Register = true, ServerUrl = wDotyk.PushServer.Text, LogVerbosity = (LogLevel)Enum.Parse(typeof(LogLevel), wDotyk.PushVerb.SelectedValue.ToString()), PackagePath = wDotyk.PushPackage.Text,//packagePath, Feed = /*Store.Model.*/PackageFeed.Test, DotykMeToken = wDotyk.PushToken.Text, UseDotykMe = true }; try { OutputsWindow.outputPane.Activate(); await pushOption.ExecuteAsync(); } catch (Exception ex) { Debug.Write(ex.Message); } } else MessageBox.Show("field \"ProjectPath\" is required"); } else { MessageBox.Show("No Project"); } else { MessageBox.Show("No Solution"); } }