diff --git a/dev/WinUICommunity_VS_Templates/Common/PreDefinedLibrary.cs b/dev/WinUICommunity_VS_Templates/Common/PreDefinedLibrary.cs index 4413a9a..934a8c6 100644 --- a/dev/WinUICommunity_VS_Templates/Common/PreDefinedLibrary.cs +++ b/dev/WinUICommunity_VS_Templates/Common/PreDefinedLibrary.cs @@ -97,7 +97,7 @@ public static List InitUseful() List list = new() { new Library("TenMica", "1.0.0-beta", false, true), - new Library("WinUI.TableView", "1.0.0-preview4", false, true), + new Library("WinUI.TableView", "1.0.0"), new Library("Microsoft.Windows.CsWinRT", "2.0.7"), new Library("Microsoft.Windows.CsWin32", "0.3.49-beta", false, true), new Library("WinUIEx", "2.3.4"), @@ -110,7 +110,7 @@ public static List InitUseful() new Library("YamlDotNet", "15.1.2"), new Library("System.Drawing.Common", "8.0.4"), new Library("System.Management", "8.0.0"), - new Library("SharpCompress", "0.36.0"), + new Library("SharpCompress", "0.37.2"), new Library("RestSharp", "110.2.0"), new Library("Vanara.Windows.Shell", "4.0.0"), new Library("protobuf-net", "3.2.30"), @@ -125,11 +125,11 @@ public static List InitWinUICommunity() { List list = new() { - new Library(Constants.WinUICommunity_Win2D, "6.7.0"), - new Library(Constants.WinUICommunity_Core, "6.7.0"), - new Library(Constants.WinUICommunity_Components, "6.7.0"), - new Library(Constants.WinUICommunity_LandingPages, "6.7.0"), - new Library(Constants.WinUICommunity_ContextMenuExtensions, "6.7.0") + new Library(Constants.WinUICommunity_Win2D, "6.8.0"), + new Library(Constants.WinUICommunity_Core, "6.8.0"), + new Library(Constants.WinUICommunity_Components, "6.8.0"), + new Library(Constants.WinUICommunity_LandingPages, "6.8.0"), + new Library(Constants.WinUICommunity_ContextMenuExtensions, "6.8.0") }; return list; } @@ -143,7 +143,7 @@ public static List InitLog() new Library("Serilog.Sinks.Debug", "2.0.0"), new Library("Serilog.Sinks.Console", "5.0.1"), new Library("log4net", "2.0.17"), - new Library("NLog", "5.2.8") + new Library("NLog", "5.3.2") }; return list; } diff --git a/dev/WinUICommunity_VS_Templates/TemplateWizard/SharedWizard.cs b/dev/WinUICommunity_VS_Templates/TemplateWizard/SharedWizard.cs index fc22d16..3e30dc0 100644 --- a/dev/WinUICommunity_VS_Templates/TemplateWizard/SharedWizard.cs +++ b/dev/WinUICommunity_VS_Templates/TemplateWizard/SharedWizard.cs @@ -41,7 +41,7 @@ public class SharedWizard private IComponentModel _componentModel; private IEnumerable _nuGetPackages; private IVsNuGetProjectUpdateEvents _nugetProjectUpdateEvents; - + private IVsThreadedWaitDialog2 _waitDialog; public void ProjectFinishedGenerating(Project project) { _project = project; @@ -97,6 +97,7 @@ public async void RunStarted(object automationObject, Dictionary { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _componentModel = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)); + _waitDialog = ServiceProvider.GlobalProvider.GetService(typeof(SVsThreadedWaitDialog)) as IVsThreadedWaitDialog2; if (_componentModel != null) { _nugetProjectUpdateEvents = _componentModel.GetService(); @@ -580,29 +581,40 @@ public async void CopyFileToDestination(string inputfile, string outputfile) return (folderPath, projectTemplatesFolder, vstemplateFileName); } - private async Task InstallNuGetPackageAsync(IVsPackageInstaller2 installer, string packageId, string source) + private async Task InstallNuGetPackagesAsync() { - await Task.Run(() => + await ThreadHelper.JoinableTaskFactory.RunAsync(async () => { - try - { - installer.InstallLatestPackage(source, _project, packageId, false, false); - // If there's any CPU-bound work, it will be done on the background thread. - } - catch (Exception ex) + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + int canceled; // This variable will store the status after the dialog is closed + + // Start the package installation task but do not await it here + var installationTask = StartInstallationAsync(); + + // Start the threaded wait dialog + _waitDialog.StartWaitDialog("Installing NuGet packages", "Please wait while NuGet packages are being installed to your project...", null, null, "Operation in progress...", 0, false, true); + + // Now await the installation task to complete + await installationTask; + + // Once the installation is complete, end the wait dialog + _waitDialog.EndWaitDialog(out canceled); + // Check if the process was canceled before proceeding + if (canceled == 0) // If not canceled, finalize the process { - LogError($"Error installing package {packageId}: {ex.Message}"); + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + SaveAllProjects(); } }); } - // InstallNuGetPackagesAsync iterates over the package list and installs each - private async Task InstallNuGetPackagesAsync() + + private async Task StartInstallationAsync() { IVsPackageInstaller2 installer = _componentModel.GetService(); if (installer == null) { LogError("Could not obtain IVsPackageInstaller service."); - + return; } foreach (var packageId in _nuGetPackages) @@ -633,10 +645,20 @@ private async Task InstallNuGetPackagesAsync() LogError($"Failed to install NuGet package: {packageId}. Error: {ex.Message}"); } } - - await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - SaveAllProjects(); } + private async Task InstallNuGetPackageAsync(IVsPackageInstaller2 installer, string packageId, string source) + { + try + { + // Simulate or perform package installation, which might be CPU-bound + await Task.Run(() => installer.InstallLatestPackage(source, _project, packageId, false, false)); + } + catch (Exception ex) + { + LogError($"Error installing package {packageId}: {ex.Message}"); + } + } + private void SaveAllProjects() { ThreadHelper.ThrowIfNotOnUIThread("SaveAllProjects must be called on the UI thread."); diff --git a/dev/WinUICommunity_VS_Templates/WinUICommunity_VS_TemplatesPackage.cs b/dev/WinUICommunity_VS_Templates/WinUICommunity_VS_TemplatesPackage.cs index aa679e7..c4b0840 100644 --- a/dev/WinUICommunity_VS_Templates/WinUICommunity_VS_TemplatesPackage.cs +++ b/dev/WinUICommunity_VS_Templates/WinUICommunity_VS_TemplatesPackage.cs @@ -46,7 +46,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. - await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); } #endregion diff --git a/dev/WinUICommunity_VS_Templates/source.extension.vsixmanifest b/dev/WinUICommunity_VS_Templates/source.extension.vsixmanifest index af8e798..00e6a10 100644 --- a/dev/WinUICommunity_VS_Templates/source.extension.vsixmanifest +++ b/dev/WinUICommunity_VS_Templates/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + WinUICommunity Templates for WinUI WinUICommunity Project Template, help you quickly create a new WinUI 3 App with WinUICommunity and MVVM Packages. We prepare your project with the following features: NavigationView, Custom TitleBar, HomeLandingPage and Settings Page (with Theme settings). We also always use the latest version of WindowsAppSDK.