diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffbad3..a793a14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +39.0.1 +* A new script, "install-desktop.sh", allows installing GNOME, KDE, XFCE, or LXDE Desktops Environments with minimal manual steps or configuration. +* Improved Windows Terminal Shell Integration with built-in support for "Opening new tabs in the same working directory" and + "Show marks for each command in the scrollbar," and by adding some actions in the settings.json file, "Automatically jump between commands," and "Select the entire output of a command." +* [FIX] After performing a Reset in App Settings, the distro can be installed again without reinstalling the app. +* [FIX] Now, if you configure Fedora Remix as your Default Profile in Windows Terminal, right-click a folder in File Explorer, and select Open in Terminal, it will correctly open in the desired directory. 39.0.0 * Upgraded to Fedora 39 diff --git a/DistroLauncher/DistroLauncher.cpp b/DistroLauncher/DistroLauncher.cpp index 1d22644..854e303 100644 --- a/DistroLauncher/DistroLauncher.cpp +++ b/DistroLauncher/DistroLauncher.cpp @@ -173,7 +173,8 @@ fire_and_forget SyncBackground() fire_and_forget ShowFedoraRemixUi() { // ReSharper disable once CppTooWideScope - const auto file = + // ReSharper disable once CppTooWideScopeInitStatement + const IStorageItem file = co_await ApplicationData::Current().LocalFolder().TryGetItemAsync(L"MicrosoftStoreEngagementSDKId.txt"); if (!file) @@ -187,6 +188,32 @@ fire_and_forget ShowFedoraRemixUi() } } +bool IsCurrentDirNotSystem32() +{ + wchar_t system32Dir[MAX_PATH]; + GetSystemDirectoryW(system32Dir, MAX_PATH); + + wchar_t currentDir[MAX_PATH]; + GetCurrentDirectoryW(MAX_PATH, currentDir); + + return _wcsicmp(system32Dir, currentDir) != 0; +} + +void CheckIfAResetWasMade() +{ + const auto localStateFolder = ApplicationData::Current().LocalFolder(); + const auto files = localStateFolder.GetFilesAsync().get(); + const bool isLocalStateEmpty = files.Size() == 0; + + if (!isLocalStateEmpty || !g_wslApi.WslIsDistributionRegistered()) + { + return; + } + + // ReSharper disable once CppExpressionWithoutSideEffects + g_wslApi.WslUnregisterDistribution(); +} + int wmain(int argc, const wchar_t* argv[]) { // Update the title bar of the console window. @@ -212,6 +239,8 @@ int wmain(int argc, const wchar_t* argv[]) return exitCode; } + CheckIfAResetWasMade(); + // Install the distribution if it is not already. const auto installOnly = arguments.size() > 0 && arguments[0] == ARG_INSTALL; auto hr = S_OK; @@ -247,7 +276,11 @@ int wmain(int argc, const wchar_t* argv[]) if (arguments.empty()) { - hr = g_wslApi.WslLaunchInteractive(L"", false, &exitCode); + /* If the current working dir is not System32 then it was called from Open with Terminal + option or from command line. In this case is better to start the distro in the current directory */ + const bool useCurrentWorkingDirectory = IsCurrentDirNotSystem32(); + + hr = g_wslApi.WslLaunchInteractive(L"", useCurrentWorkingDirectory, &exitCode); // Check exitCode to see if wsl.exe returned that it could not start the Linux process // then prompt users for input so they can view the error message. @@ -292,8 +325,9 @@ int wmain(int argc, const wchar_t* argv[]) } else { + // ReSharper disable once CppFunctionResultShouldBeUsed Helpers::PrintMessage(MSG_USAGE); - return exitCode; + return static_cast(exitCode); } } diff --git a/DistroLauncher/DistroLauncher.vcxproj b/DistroLauncher/DistroLauncher.vcxproj index 1daa3da..68ba9d2 100644 --- a/DistroLauncher/DistroLauncher.vcxproj +++ b/DistroLauncher/DistroLauncher.vcxproj @@ -1,6 +1,6 @@ - + Debug @@ -23,7 +23,7 @@ {BA627106-E5F7-46EE-B8D7-2D5A760F2FB2} Win32Proj DistroLauncher - 10.0 + 10.0.22621.0 Launcher @@ -155,6 +155,7 @@ + @@ -189,13 +190,13 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + \ No newline at end of file diff --git a/DistroLauncher/DistroLauncher.vcxproj.filters b/DistroLauncher/DistroLauncher.vcxproj.filters index 9b5c1c9..a7a1dac 100644 --- a/DistroLauncher/DistroLauncher.vcxproj.filters +++ b/DistroLauncher/DistroLauncher.vcxproj.filters @@ -33,6 +33,9 @@ Header Files + + Header Files + diff --git a/DistroLauncher/WslApiLoader.cpp b/DistroLauncher/WslApiLoader.cpp index fbcc475..d9fd67e 100644 --- a/DistroLauncher/WslApiLoader.cpp +++ b/DistroLauncher/WslApiLoader.cpp @@ -9,12 +9,13 @@ WslApiLoader::WslApiLoader(const std::wstring& distributionName) : _distributionName(distributionName) { - _wslApiDll = LoadLibraryEx(L"wslapi.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + _wslApiDll = LoadLibraryExW(L"wslapi.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); if (_wslApiDll != nullptr) { _isDistributionRegistered = (WSL_IS_DISTRIBUTION_REGISTERED)GetProcAddress( _wslApiDll, "WslIsDistributionRegistered"); _registerDistribution = (WSL_REGISTER_DISTRIBUTION)GetProcAddress(_wslApiDll, "WslRegisterDistribution"); + _unRegisterDistribution = (WSL_UN_REGISTER_DISTRIBUTION)GetProcAddress(_wslApiDll, "WslUnregisterDistribution"); _configureDistribution = (WSL_CONFIGURE_DISTRIBUTION)GetProcAddress(_wslApiDll, "WslConfigureDistribution"); _launchInteractive = (WSL_LAUNCH_INTERACTIVE)GetProcAddress(_wslApiDll, "WslLaunchInteractive"); _launch = (WSL_LAUNCH)GetProcAddress(_wslApiDll, "WslLaunch"); @@ -29,24 +30,24 @@ WslApiLoader::~WslApiLoader() } } -BOOL WslApiLoader::WslIsOptionalComponentInstalled() const +BOOL WslApiLoader::WslIsOptionalComponentInstalled() { - return ((_wslApiDll != nullptr) && - (_isDistributionRegistered != nullptr) && - (_registerDistribution != nullptr) && - (_configureDistribution != nullptr) && - (_launchInteractive != nullptr) && - (_launch != nullptr)); + return _wslApiDll != nullptr && + _isDistributionRegistered != nullptr && + _registerDistribution != nullptr && + _configureDistribution != nullptr && + _launchInteractive != nullptr && + _launch != nullptr; } -BOOL WslApiLoader::WslIsDistributionRegistered() const +BOOL WslApiLoader::WslIsDistributionRegistered() { return _isDistributionRegistered(_distributionName.c_str()); } -HRESULT WslApiLoader::WslRegisterDistribution() const +HRESULT WslApiLoader::WslRegisterDistribution() { - const auto hr = _registerDistribution(_distributionName.c_str(), L"install.tar.gz"); + const HRESULT hr = _registerDistribution(_distributionName.c_str(), L"install.tar.gz"); if (FAILED(hr)) { Helpers::PrintMessage(MSG_WSL_REGISTER_DISTRIBUTION_FAILED, hr); @@ -55,9 +56,21 @@ HRESULT WslApiLoader::WslRegisterDistribution() const return hr; } -HRESULT WslApiLoader::WslConfigureDistribution(ULONG defaultUID, WSL_DISTRIBUTION_FLAGS wslDistributionFlags) const +HRESULT WslApiLoader::WslUnregisterDistribution() const { - const auto hr = _configureDistribution(_distributionName.c_str(), defaultUID, wslDistributionFlags); + const auto hr = _unRegisterDistribution(_distributionName.c_str()); + if (FAILED(hr)) + { + wprintf(L"failed"); + Helpers::PrintMessage(MSG_WSL_UN_REGISTER_DISTRIBUTION_FAILED, hr); + } + + return hr; +} + +HRESULT WslApiLoader::WslConfigureDistribution(ULONG defaultUID, WSL_DISTRIBUTION_FLAGS wslDistributionFlags) +{ + const HRESULT hr = _configureDistribution(_distributionName.c_str(), defaultUID, wslDistributionFlags); if (FAILED(hr)) { Helpers::PrintMessage(MSG_WSL_CONFIGURE_DISTRIBUTION_FAILED, hr); @@ -66,9 +79,9 @@ HRESULT WslApiLoader::WslConfigureDistribution(ULONG defaultUID, WSL_DISTRIBUTIO return hr; } -HRESULT WslApiLoader::WslLaunchInteractive(PCWSTR command, BOOL useCurrentWorkingDirectory, DWORD* exitCode) const +HRESULT WslApiLoader::WslLaunchInteractive(PCWSTR command, BOOL useCurrentWorkingDirectory, DWORD* exitCode) { - const auto hr = _launchInteractive(_distributionName.c_str(), command, useCurrentWorkingDirectory, exitCode); + const HRESULT hr = _launchInteractive(_distributionName.c_str(), command, useCurrentWorkingDirectory, exitCode); if (FAILED(hr)) { Helpers::PrintMessage(MSG_WSL_LAUNCH_INTERACTIVE_FAILED, command, hr); @@ -78,10 +91,10 @@ HRESULT WslApiLoader::WslLaunchInteractive(PCWSTR command, BOOL useCurrentWorkin } HRESULT WslApiLoader::WslLaunch(PCWSTR command, BOOL useCurrentWorkingDirectory, HANDLE stdIn, HANDLE stdOut, - HANDLE stdErr, HANDLE* process) const + HANDLE stdErr, HANDLE* process) { - const auto hr = _launch(_distributionName.c_str(), command, useCurrentWorkingDirectory, stdIn, stdOut, stdErr, - process); + const HRESULT hr = _launch(_distributionName.c_str(), command, useCurrentWorkingDirectory, stdIn, stdOut, stdErr, + process); if (FAILED(hr)) { Helpers::PrintMessage(MSG_WSL_LAUNCH_FAILED, command, hr); diff --git a/DistroLauncher/WslApiLoader.h b/DistroLauncher/WslApiLoader.h index 4db0968..ec027ee 100644 --- a/DistroLauncher/WslApiLoader.h +++ b/DistroLauncher/WslApiLoader.h @@ -13,6 +13,7 @@ using WSL_IS_DISTRIBUTION_REGISTERED = BOOL(STDAPICALLTYPE*)(PCWSTR); using WSL_REGISTER_DISTRIBUTION = HRESULT(STDAPICALLTYPE*)(PCWSTR, PCWSTR); +using WSL_UN_REGISTER_DISTRIBUTION = HRESULT(STDAPICALLTYPE*)(PCWSTR); using WSL_CONFIGURE_DISTRIBUTION = HRESULT(STDAPICALLTYPE*)(PCWSTR, ULONG, WSL_DISTRIBUTION_FLAGS); using WSL_GET_DISTRIBUTION_CONFIGURATION = HRESULT(STDAPICALLTYPE*)(PCWSTR, ULONG*, ULONG*, WSL_DISTRIBUTION_FLAGS*, PSTR**, ULONG*); @@ -25,31 +26,34 @@ class WslApiLoader WslApiLoader(const std::wstring& distributionName); ~WslApiLoader(); - BOOL WslIsOptionalComponentInstalled() const; + BOOL WslIsOptionalComponentInstalled(); - BOOL WslIsDistributionRegistered() const; + BOOL WslIsDistributionRegistered(); - HRESULT WslRegisterDistribution() const; + HRESULT WslRegisterDistribution(); + + HRESULT WslUnregisterDistribution() const; HRESULT WslConfigureDistribution(ULONG defaultUID, - WSL_DISTRIBUTION_FLAGS wslDistributionFlags) const; + WSL_DISTRIBUTION_FLAGS wslDistributionFlags); HRESULT WslLaunchInteractive(PCWSTR command, BOOL useCurrentWorkingDirectory, - DWORD* exitCode) const; + DWORD* exitCode); HRESULT WslLaunch(PCWSTR command, BOOL useCurrentWorkingDirectory, HANDLE stdIn, HANDLE stdOut, HANDLE stdErr, - HANDLE* process) const; + HANDLE* process); private: std::wstring _distributionName; HMODULE _wslApiDll; WSL_IS_DISTRIBUTION_REGISTERED _isDistributionRegistered; WSL_REGISTER_DISTRIBUTION _registerDistribution; + WSL_UN_REGISTER_DISTRIBUTION _unRegisterDistribution; WSL_CONFIGURE_DISTRIBUTION _configureDistribution; WSL_LAUNCH_INTERACTIVE _launchInteractive; WSL_LAUNCH _launch; diff --git a/DistroLauncher/messages.mc b/DistroLauncher/messages.mc index c0c715c..7b1799b 100644 --- a/DistroLauncher/messages.mc +++ b/DistroLauncher/messages.mc @@ -108,3 +108,8 @@ Language=English Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS. For information please visit https://aka.ms/enablevirtualization . + +MessageId=1017 SymbolicName=MSG_WSL_UN_REGISTER_DISTRIBUTION_FAILED +Language=English +WslUnRegisterDistribution failed with error: 0x%1!x! +. diff --git a/DistroLauncher/packages.config b/DistroLauncher/packages.config index 614e599..1b8cfbd 100644 --- a/DistroLauncher/packages.config +++ b/DistroLauncher/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/DistroLauncher/stdafx.h b/DistroLauncher/stdafx.h index 135d2e1..15b5e39 100644 --- a/DistroLauncher/stdafx.h +++ b/DistroLauncher/stdafx.h @@ -25,6 +25,10 @@ #include #include #include + +#include +#include + #include "DistributionInfo.h" #include "Helpers.h" #include "WslApiLoader.h" diff --git a/Fedora-Remix-for-WSL-SL/Package.appxmanifest b/Fedora-Remix-for-WSL-SL/Package.appxmanifest index 715c077..62bb052 100644 --- a/Fedora-Remix-for-WSL-SL/Package.appxmanifest +++ b/Fedora-Remix-for-WSL-SL/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="39.0.1.0"/> Fedora Remix for WSL diff --git a/Fedora-Remix-for-WSL/Package.appxmanifest b/Fedora-Remix-for-WSL/Package.appxmanifest index 3434c46..d883553 100644 --- a/Fedora-Remix-for-WSL/Package.appxmanifest +++ b/Fedora-Remix-for-WSL/Package.appxmanifest @@ -12,7 +12,7 @@ + Version="39.0.1.0"/> Fedora Remix for WSL diff --git a/FedoraRemixWSLUI/FedoraRemixWSLUI.vcxproj b/FedoraRemixWSLUI/FedoraRemixWSLUI.vcxproj index 67a9ceb..7dcfe7d 100644 --- a/FedoraRemixWSLUI/FedoraRemixWSLUI.vcxproj +++ b/FedoraRemixWSLUI/FedoraRemixWSLUI.vcxproj @@ -1,6 +1,6 @@  - + true true @@ -161,15 +161,15 @@ - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + \ No newline at end of file diff --git a/FedoraRemixWSLUI/packages.config b/FedoraRemixWSLUI/packages.config index 00d4782..061e72b 100644 --- a/FedoraRemixWSLUI/packages.config +++ b/FedoraRemixWSLUI/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/appMetadata/en-us/baseListing/releaseNotes.txt b/appMetadata/en-us/baseListing/releaseNotes.txt index b91a15d..47e0ca4 100644 --- a/appMetadata/en-us/baseListing/releaseNotes.txt +++ b/appMetadata/en-us/baseListing/releaseNotes.txt @@ -1,5 +1,12 @@ Existing users can update immediately by running $ update.sh +39.0.1 +* A new script, "install-desktop.sh", allows installing GNOME, KDE, XFCE, or LXDE Desktops Environments with minimal manual steps or configuration. +* Improved Windows Terminal Shell Integration with built-in support for "Opening new tabs in the same working directory" and +"Show marks for each command in the scrollbar," and by adding some actions in the settings.json file, "Automatically jump between commands," and "Select the entire output of a command." +* [FIX] After performing a Reset in App Settings, the distro can be installed again without reinstalling the app. +* [FIX] Now, if you configure Fedora Remix as your Default Profile in Windows Terminal, right-click a folder in File Explorer, and select Open in Terminal, it will correctly open in the desired directory. + 39.0.0 * Upgraded to Fedora 39 * Fedora Linux 39 now features a coloured Bash prompt by default! @@ -14,22 +21,3 @@ Existing users can update immediately by running $ update.sh 37.2.0 * Latest update for Fedora 37 * Upgraded mesa to 23.0.2 which includes some fixes to the VP9 video decoder - -37.1.2 -* Support GPU video decoding and encoding in WSLg - -37.1.0 -* Upgrade Mesa to 22.3.6 -* Fix ping in WSL1 -* Upgrade to WSL Utilities 4.1.1 - -37.0.4 -* Stop trying to upgrade fedora remix if the SystemD script fails - -37.0.2 -* Upgraded to Fedora 37 -* Improved compatibility with the Windows built-in SystemD - -36.0.1 -* Upgraded to Fedora 36 -