-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation for Portable install flow #2078
Conversation
… portableInstallFlow
constexpr std::wstring_view s_UninstallRegistryX64 = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
constexpr std::wstring_view s_UninstallRegistryX86 = L"Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
constexpr std::wstring_view s_DisplayName = L"DisplayName"; | ||
constexpr std::wstring_view s_DisplayVersion = L"DisplayVersion"; | ||
constexpr std::wstring_view s_Publisher = L"Publisher"; | ||
constexpr std::wstring_view s_InstallDate = L"InstallDate"; | ||
constexpr std::wstring_view s_URLInfoAbout = L"URLInfoAbout"; | ||
constexpr std::wstring_view s_HelpLink = L"HelpLink"; | ||
constexpr std::wstring_view s_UninstallString = L"UninstallString"; | ||
constexpr std::wstring_view s_WinGetInstallerType = L"WinGetInstallerType"; | ||
constexpr std::wstring_view s_InstallLocation = L"InstallLocation"; | ||
constexpr std::wstring_view s_PortableTargetFullPath = L"TargetFullPath"; | ||
constexpr std::wstring_view s_PortableSymlinkFullPath = L"SymlinkFullPath"; | ||
constexpr std::wstring_view s_SHA256 = L"SHA256"; | ||
constexpr std::wstring_view s_WinGetPackageIdentifier = L"WinGetPackageIdentifier"; | ||
constexpr std::wstring_view s_WinGetSourceIdentifier = L"WinGetSourceIdentifier"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you put these inside of a map and then use the map as a dictionary later instead of using all of the if..else if..else statements in the ToString method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a map for these strings as suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A switch statement would be the preferred way to do ToString
. And I would use a macro to stamp out the cases since the enum value and static string can shared a common name fragment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a macro to stamp out cases and use a switch statement. Removed map
constexpr std::wstring_view s_UninstallRegistryX64 = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
constexpr std::wstring_view s_UninstallRegistryX86 = L"Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; | ||
constexpr std::wstring_view s_DisplayName = L"DisplayName"; | ||
constexpr std::wstring_view s_DisplayVersion = L"DisplayVersion"; | ||
constexpr std::wstring_view s_Publisher = L"Publisher"; | ||
constexpr std::wstring_view s_InstallDate = L"InstallDate"; | ||
constexpr std::wstring_view s_URLInfoAbout = L"URLInfoAbout"; | ||
constexpr std::wstring_view s_HelpLink = L"HelpLink"; | ||
constexpr std::wstring_view s_UninstallString = L"UninstallString"; | ||
constexpr std::wstring_view s_WinGetInstallerType = L"WinGetInstallerType"; | ||
constexpr std::wstring_view s_InstallLocation = L"InstallLocation"; | ||
constexpr std::wstring_view s_PortableTargetFullPath = L"TargetFullPath"; | ||
constexpr std::wstring_view s_PortableSymlinkFullPath = L"SymlinkFullPath"; | ||
constexpr std::wstring_view s_SHA256 = L"SHA256"; | ||
constexpr std::wstring_view s_WinGetPackageIdentifier = L"WinGetPackageIdentifier"; | ||
constexpr std::wstring_view s_WinGetSourceIdentifier = L"WinGetSourceIdentifier"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A switch statement would be the preferred way to do ToString
. And I would use a macro to stamp out the cases since the enum value and static string can shared a common name fragment.
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentactivatable amd Archs dsc enr FWW Globals hackathon lww mytool OSVERSION Packagedx parametermap symlink Uninitialize WDAG whatif wsbTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:ryfu-msft/winget-cli.git repository
|
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
} | ||
else | ||
{ | ||
source = s_LocalSource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to include the asterisk in the package Identifier? Technically it is an allowed character, but knowing that users may use powershell, and for potential forward compatibility, it may be best to omit it from the product code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that for consistency this function should apply MakeSuitablePathPart
before returning, which will remove the *
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably a good call. As we don't have wildcard support, and some terminals might do unexpected things.
AICLI_LOG(CLI, Info, << "Writing to Uninstall registry complete."); | ||
} | ||
|
||
void MovePortableExeAndCreateSymlink(Execution::Context& context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what it is, but something about this name just doesn't seem right. I think it is the And
which indicates that this task is doing two tasks and that it may be best to split it into one task for moving the exe, and one for creating the symlink? I'm not an expert though, so I'd like others' opinions on this too
cc @JohnMcPMS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it would generally make more sense to split the two operations if they are logically independent. I don't think that we need to now, but I definitely foresee the need for this in the future for portable(s) in an archive support, where it isn't just a single file and symlink. I think it can wait until then though.
As for the name, again I'm fine with it for now because I expect it to be refactored for the archive support.
auto now = std::chrono::system_clock::now(); | ||
std::time_t tt = std::chrono::system_clock::to_time_t(now); | ||
|
||
struct tm newTime; | ||
localtime_s(&newTime, &tt); | ||
|
||
std::stringstream ss; | ||
ss << std::put_time(&newTime, "%Y%m%d"); | ||
return ss.str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have to use std::chrono::system_clock::now()
? Or would this work?
auto now = std::chrono::system_clock::now(); | |
std::time_t tt = std::chrono::system_clock::to_time_t(now); | |
struct tm newTime; | |
localtime_s(&newTime, &tt); | |
std::stringstream ss; | |
ss << std::put_time(&newTime, "%Y%m%d"); | |
return ss.str(); | |
std::time_t now = std::time(nullptr); | |
std::stringstream ss; | |
ss << std::put_time(std::localtime(&now), "%Y%m%d"); | |
return ss.str(); |
(Just trying to learn, so this might not be right)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks correct to me (although nullptr
is preferred over 0
).
Although if we convert to C++20, we can just get the time formatting goodness and not use the icky C stuff.
} | ||
else | ||
{ | ||
source = s_LocalSource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that for consistency this function should apply MakeSuitablePathPart
before returning, which will remove the *
.
AICLI_LOG(CLI, Info, << "Writing to Uninstall registry complete."); | ||
} | ||
|
||
void MovePortableExeAndCreateSymlink(Execution::Context& context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it would generally make more sense to split the two operations if they are logically independent. I don't think that we need to now, but I definitely foresee the need for this in the future for portable(s) in an archive support, where it isn't just a single file and symlink. I think it can wait until then though.
As for the name, again I'm fine with it for now because I expect it to be refactored for the archive support.
auto now = std::chrono::system_clock::now(); | ||
std::time_t tt = std::chrono::system_clock::to_time_t(now); | ||
|
||
struct tm newTime; | ||
localtime_s(&newTime, &tt); | ||
|
||
std::stringstream ss; | ||
ss << std::put_time(&newTime, "%Y%m%d"); | ||
return ss.str(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks correct to me (although nullptr
is preferred over 0
).
Although if we convert to C++20, we can just get the time formatting goodness and not use the icky C stuff.
🎉 |
We will look to cut another preview build ASAP 😊 |
Potential for CI/CD pre-releases after every PR merge? |
It would have to be of the dev package due to policies. But the pipeline could be updated to create a package, sign it, and leave it in the artifacts. |
I think that would be great to have a WingetDev build accessible in the public artifacts of a pipeline in case some power users want to really test things before they hit an official pre-release |
Related to:
This PR add support for the installation of portable standalone apps. The design aligns with what is specified in the portable install design spec. This PR only relates to the install command. Support for upgrade and uninstall will be handled in a separate PR.
Tests:
Microsoft Reviewers: Open in CodeFlow