commit 850a59967394adbfb9d0d8819fa54c7852ea232a
parent 3165abec5bff3bf707ebc006e89483d975fd6974
Author: Kaleb Luedtke <jluedtk@jci.com>
Date: Fri, 7 Apr 2023 16:46:03 -0500
Show Portable Installation Directories with --info (#3128)
Diffstat:
5 files changed, 87 insertions(+), 40 deletions(-)
diff --git a/src/AppInstallerCLICore/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp
@@ -126,6 +126,35 @@ namespace AppInstaller::CLI
}
adminSettingsTable.Complete();
}
+
+ void OutputKeyDirectories(Execution::Context& context)
+ {
+ Execution::TableOutput<2> keyDirectories{ context.Reporter, { Resource::String::KeyDirectoriesHeader, {} } };
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::Logs }, Runtime::GetPathTo(Runtime::PathName::DefaultLogLocation, true).u8string() });
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::UserSettings }, UserSettings::SettingsFilePath(true).u8string() });
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableLinksUser }, Runtime::GetPathTo(Runtime::PathName::PortableLinksUserLocation, true).u8string() });
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableLinksMachine }, Runtime::GetPathTo(Runtime::PathName::PortableLinksMachineLocation, true).u8string() });
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRootUser }, Runtime::GetPathTo(Runtime::PathName::PortablePackageUserRoot, true).u8string() });
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRoot86 }, Runtime::GetPathTo(Runtime::PathName::PortablePackageMachineRootX86, true).u8string() });
+ if (Utility::GetSystemArchitecture() == Utility::Architecture::X64 || Utility::GetSystemArchitecture() == Utility::Architecture::Arm64)
+ {
+ keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRoot64 }, Runtime::GetPathTo(Runtime::PathName::PortablePackageMachineRootX64, true).u8string() });
+ }
+ keyDirectories.Complete();
+ context.Reporter.Info() << std::endl;
+ }
+
+ void OutputLinks(Execution::Context& context)
+ {
+ Execution::TableOutput<2> links{ context.Reporter, { Resource::String::Links, {} } };
+ links.OutputLine({ Resource::LocString{ Resource::String::PrivacyStatement }, "https://aka.ms/winget-privacy" });
+ links.OutputLine({ Resource::LocString{ Resource::String::LicenseAgreement }, "https://aka.ms/winget-license" });
+ links.OutputLine({ Resource::LocString{ Resource::String::ThirdPartSoftwareNotices }, "https://aka.ms/winget-3rdPartyNotice" });
+ links.OutputLine({ Resource::LocString{ Resource::String::MainHomepage }, "https://aka.ms/winget" });
+ links.OutputLine({ Resource::LocString{ Resource::String::WindowsStoreTerms }, "https://www.microsoft.com/en-us/storedocs/terms-of-sale" });
+ links.Complete();
+ context.Reporter.Info() << std::endl;
+ }
}
std::vector<std::unique_ptr<Command>> RootCommand::GetCommands() const
@@ -211,22 +240,10 @@ namespace AppInstaller::CLI
info << Resource::String::Package(Runtime::GetPackageVersion()) << std::endl;
};
- info << std::endl << Resource::String::Logs(Utility::LocIndView{ Runtime::GetPathTo(Runtime::PathName::DefaultLogLocationForDisplay).u8string() }) << std::endl;
- info << std::endl << Resource::String::UserSettings(Utility::LocIndView{ UserSettings::SettingsFilePath(true).u8string() }) << std::endl;
-
- info << std::endl;
-
- Execution::TableOutput<2> links{ context.Reporter, { Resource::String::Links, {} } };
-
- links.OutputLine({ Resource::LocString(Resource::String::PrivacyStatement).get(), "https://aka.ms/winget-privacy" });
- links.OutputLine({ Resource::LocString(Resource::String::LicenseAgreement).get(), "https://aka.ms/winget-license" });
- links.OutputLine({ Resource::LocString(Resource::String::ThirdPartSoftwareNotices).get(), "https://aka.ms/winget-3rdPartyNotice" });
- links.OutputLine({ Resource::LocString(Resource::String::MainHomepage).get(), "https://aka.ms/winget" });
- links.OutputLine({ Resource::LocString(Resource::String::WindowsStoreTerms).get(), "https://www.microsoft.com/en-us/storedocs/terms-of-sale" });
-
- links.Complete();
info << std::endl;
+ OutputKeyDirectories(context);
+ OutputLinks(context);
OutputGroupPolicies(context);
OutputAdminSettings(context);
}
diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h
@@ -219,6 +219,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(InvalidJsonFile);
WINGET_DEFINE_RESOURCE_STRINGID(InvalidNameError);
WINGET_DEFINE_RESOURCE_STRINGID(InvalidPathToNestedInstaller);
+ WINGET_DEFINE_RESOURCE_STRINGID(KeyDirectoriesHeader);
WINGET_DEFINE_RESOURCE_STRINGID(LicenseAgreement);
WINGET_DEFINE_RESOURCE_STRINGID(Links);
WINGET_DEFINE_RESOURCE_STRINGID(ListCommandLongDescription);
@@ -312,8 +313,13 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(PortableHashMismatchOverrideRequired);
WINGET_DEFINE_RESOURCE_STRINGID(PortableAliasAdded);
WINGET_DEFINE_RESOURCE_STRINGID(PortableInstallFailed);
+ WINGET_DEFINE_RESOURCE_STRINGID(PortableLinksMachine);
+ WINGET_DEFINE_RESOURCE_STRINGID(PortableLinksUser);
WINGET_DEFINE_RESOURCE_STRINGID(PortablePackageAlreadyExists);
WINGET_DEFINE_RESOURCE_STRINGID(PortableRegistryCollisionOverridden);
+ WINGET_DEFINE_RESOURCE_STRINGID(PortableRoot64);
+ WINGET_DEFINE_RESOURCE_STRINGID(PortableRoot86);
+ WINGET_DEFINE_RESOURCE_STRINGID(PortableRootUser);
WINGET_DEFINE_RESOURCE_STRINGID(PositionArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PreserveArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PressEnterToContinue);
diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
@@ -319,6 +319,10 @@ They can be configured through the settings file 'winget settings'.</value>
<value>Argument name was not recognized for the current command: '{0}'</value>
<comment>{Locked="{0}"} Error message displayed when the user provides an unrecognized command line argument name for the selected command. {0} is a placeholder replaced by the user's argument name input (e.g. '--example').</comment>
</data>
+ <data name="KeyDirectoriesHeader" xml:space="preserve">
+ <value>Winget Directories</value>
+ <comment>Header for a table detailing the directories Winget uses for key operations like logging and portable installs</comment>
+ </data>
<data name="LocaleArgumentDescription" xml:space="preserve">
<value>Locale to use (BCP47 format)</value>
<comment>{Locked="BCP47"}</comment>
@@ -775,8 +779,8 @@ They can be configured through the settings file 'winget settings'.</value>
<value>Both local manifest and search query arguments are provided</value>
</data>
<data name="Logs" xml:space="preserve">
- <value>Logs: {0}</value>
- <comment>{Locked="{0}"} Label displayed for diagnostic files containing information about the application use. {0} is a placeholder replaced by the logs directory path.</comment>
+ <value>Logs</value>
+ <comment>Label displayed for diagnostic files containing information about the application use.</comment>
</data>
<data name="InstallerBlockedByPolicy" xml:space="preserve">
<value>The installer is blocked by policy</value>
@@ -1402,6 +1406,21 @@ Please specify one of them using the --source option to proceed.</value>
<data name="PortableAliasAdded" xml:space="preserve">
<value>Command line alias added:</value>
</data>
+ <data name="PortableLinksMachine" xml:space="preserve">
+ <value>Portable Links Directory (Machine)</value>
+ </data>
+ <data name="PortableLinksUser" xml:space="preserve">
+ <value>Portable Links Directory (User)</value>
+ </data>
+ <data name="PortableRootUser" xml:space="preserve">
+ <value>Portable Package Root (User)</value>
+ </data>
+ <data name="PortableRoot64" xml:space="preserve">
+ <value>Portable Package Root (x86)</value>
+ </data>
+ <data name="PortableRoot86" xml:space="preserve">
+ <value>Portable Package Root (x64)</value>
+ </data>
<data name="PortableInstallFailed" xml:space="preserve">
<value>Portable install failed; Cleaning up...</value>
</data>
@@ -1580,8 +1599,8 @@ Please specify one of them using the --source option to proceed.</value>
<value>Export settings</value>
</data>
<data name="UserSettings" xml:space="preserve">
- <value>User Settings: {0}</value>
- <comment>{Locked="{0}"} Label displayed for the file containing the user settings. {0} is a placeholder replaced by the user settings file path.</comment>
+ <value>User Settings</value>
+ <comment>Label displayed for the file containing the user settings.</comment>
</data>
<data name="SettingsWarningUsingDefault" xml:space="preserve">
<value>Settings file couldn't load. Using default values.</value>
diff --git a/src/AppInstallerCommonCore/Public/AppInstallerRuntime.h b/src/AppInstallerCommonCore/Public/AppInstallerRuntime.h
@@ -39,8 +39,6 @@ namespace AppInstaller::Runtime
LocalState,
// The default location where log files are located.
DefaultLogLocation,
- // The default location, anonymized using environment variables.
- DefaultLogLocationForDisplay,
// The location that standard type settings are stored.
// In a packaged context, this returns a prepend value for the container name.
StandardSettings,
@@ -112,10 +110,10 @@ namespace AppInstaller::Runtime
// Gets the PathDetails used for the given path.
// This is exposed primarily to allow for testing, GetPathTo should be preferred.
- PathDetails GetPathDetailsFor(PathName path);
+ PathDetails GetPathDetailsFor(PathName path, bool forDisplay = false);
// Gets the path to the requested location.
- std::filesystem::path GetPathTo(PathName path);
+ std::filesystem::path GetPathTo(PathName path, bool forDisplay = false);
// Gets a new temp file path.
std::filesystem::path GetNewTempFilePath();
diff --git a/src/AppInstallerCommonCore/Runtime.cpp b/src/AppInstallerCommonCore/Runtime.cpp
@@ -485,7 +485,7 @@ namespace AppInstaller::Runtime
}
#ifndef WINGET_DISABLE_FOR_FUZZING
- PathDetails GetPathDetailsForPackagedContext(PathName path)
+ PathDetails GetPathDetailsForPackagedContext(PathName path, bool forDisplay = false)
{
PathDetails result;
@@ -504,12 +504,10 @@ namespace AppInstaller::Runtime
result.Path.assign(appStorage.LocalFolder().Path().c_str());
break;
case PathName::DefaultLogLocation:
- case PathName::DefaultLogLocationForDisplay:
// To enable UIF collection through Feedback hub, we must put our logs here.
result.Path.assign(appStorage.LocalFolder().Path().c_str());
result.Path /= WINGET_DEFAULT_LOG_DIRECTORY;
-
- if (path == PathName::DefaultLogLocationForDisplay)
+ if (forDisplay)
{
ReplaceCommonPathPrefix(result.Path, GetKnownFolderPath(FOLDERID_LocalAppData), "%LOCALAPPDATA%");
}
@@ -536,13 +534,19 @@ namespace AppInstaller::Runtime
}
break;
case PathName::UserProfile:
- case PathName::PortablePackageUserRoot:
case PathName::PortablePackageMachineRootX64:
case PathName::PortablePackageMachineRootX86:
- case PathName::PortableLinksUserLocation:
case PathName::PortableLinksMachineLocation:
result = GetPathDetailsCommon(path);
break;
+ case PathName::PortableLinksUserLocation:
+ case PathName::PortablePackageUserRoot:
+ result = GetPathDetailsCommon(path);
+ if (forDisplay)
+ {
+ ReplaceCommonPathPrefix(result.Path, GetKnownFolderPath(FOLDERID_LocalAppData), "%LOCALAPPDATA%");
+ }
+ break;
case PathName::SelfPackageRoot:
result.Path = GetPackagePath();
result.Create = false;
@@ -555,7 +559,7 @@ namespace AppInstaller::Runtime
}
#endif
- PathDetails GetPathDetailsForUnpackagedContext(PathName path)
+ PathDetails GetPathDetailsForUnpackagedContext(PathName path, bool forDisplay = false)
{
PathDetails result;
@@ -564,7 +568,16 @@ namespace AppInstaller::Runtime
case PathName::Temp:
case PathName::DefaultLogLocation:
{
- result.Path = GetPathToUserTemp();
+ if (forDisplay)
+ {
+ result.Path.assign("%TEMP%");
+ result.Create = false;
+ }
+ else
+ {
+ result.Path = GetPathToUserTemp();
+ }
+
result.Path /= s_DefaultTempDirectory;
result.Path /= GetRuntimePathStateName();
if (path == PathName::Temp)
@@ -575,12 +588,6 @@ namespace AppInstaller::Runtime
}
}
break;
- case PathName::DefaultLogLocationForDisplay:
- result.Path.assign("%TEMP%");
- result.Path /= s_DefaultTempDirectory;
- result.Path /= GetRuntimePathStateName();
- result.Create = false;
- break;
case PathName::LocalState:
result.Path = GetPathToAppDataDir(s_AppDataDir_State);
result.Path /= GetRuntimePathStateName();
@@ -629,14 +636,14 @@ namespace AppInstaller::Runtime
return result;
}
- PathDetails GetPathDetailsFor(PathName path)
+ PathDetails GetPathDetailsFor(PathName path, bool forDisplay)
{
PathDetails result;
#ifndef WINGET_DISABLE_FOR_FUZZING
if (IsRunningInPackagedContext())
{
- result = GetPathDetailsForPackagedContext(path);
+ result = GetPathDetailsForPackagedContext(path, forDisplay);
}
else
#endif
@@ -656,9 +663,9 @@ namespace AppInstaller::Runtime
return result;
}
- std::filesystem::path GetPathTo(PathName path)
+ std::filesystem::path GetPathTo(PathName path, bool forDisplay)
{
- PathDetails details = GetPathDetailsFor(path);
+ PathDetails details = GetPathDetailsFor(path, forDisplay);
if (details.Create)
{