mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Self-contained .NET (#22217)
* dotnet sc
* MD preview - C# app
- working self-contained
* Gcode preview - C# app
* DevFiles preview - C# app
* Fix passing path with spaces as cmd arg and monacocpp proj file
* Pdf preview - C# app
* Svg preview - C# app
* Fix comment
* Gcode thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Pdf thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Pdf thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Fix GcodeThumbnailProviderCpp.vcxproj
* Svg thumbnail - C# app
TODO:
- installer
- why IThumbnailProvider and IIntializeWithFile doesn't work?
* Fix Svg tests
* Thumbnail providers - installer
* Self-contained Hosts and FileLocksmith
* Fix hardcoded <RuntimeIdentifier>
* Remove unneeded files
* Try to fix Nuget in PR CI
* Prefix new dlls with PowerToys.
Sign new dlls and exes
* Add new .exe files to ProcessList
* ci: debug by listing all env vars
* ci: try setting variable in the right ci file
* Bring back hardcoded RuntimeIdentifier
* ci: Add comment and remove debug action
* Remove unneeded lib
* [WIP] Platform conditional dotnet files & hardlinks
* Cleanup
* Update expect.txt
* Test fix - ARM installer
* Fix uninstall bug
* Update docs
* Fix failing test
* Add dll details
* Minor cleanup
* Improve resizing
* Add some logs
* Test fix - release build
* Remove InvokeOnControlThread
* Test fix: logger initialization
* Fix arm64 installer
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
This commit is contained in:
@@ -207,5 +207,24 @@ public
|
||||
return gcnew String(CommonSharedConstants::POWERACCENT_EXIT_EVENT);
|
||||
}
|
||||
|
||||
static String ^ GcodePreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ DevFilesPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::DEV_FILES_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ MarkdownPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::MARKDOWN_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ PdfPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::PDF_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
|
||||
static String ^ SvgPreviewResizeEvent() {
|
||||
return gcnew String(CommonSharedConstants::SVG_PREVIEW_RESIZE_EVENT);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,6 +44,21 @@ namespace CommonSharedConstants
|
||||
// Path to the event used by PowerOCR
|
||||
const wchar_t SHOW_POWEROCR_SHARED_EVENT[] = L"Local\\PowerOCREvent-dc864e06-e1af-4ecc-9078-f98bee745e3a";
|
||||
|
||||
// Path to the event used by GcodePreviewHandler
|
||||
const wchar_t GCODE_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysGcodePreviewResizeEvent-6ff1f9bd-ccbd-4b24-a79f-40a34fb0317d";
|
||||
|
||||
// Path to the event used by DevFilesPreviewHandler
|
||||
const wchar_t DEV_FILES_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysDevFilesPreviewResizeEvent-5707a22c-2cac-4ea2-82f0-27c03ef0b5f3";
|
||||
|
||||
// Path to the event used by MarkdownPreviewHandler
|
||||
const wchar_t MARKDOWN_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysMarkdownPreviewResizeEvent-54c9ab69-11f3-49e9-a98f-53221cfef3ec";
|
||||
|
||||
// Path to the event used by MarkdownPreviewHandler
|
||||
const wchar_t PDF_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysPdfPreviewResizeEvent-5a2f162a-f728-45fe-8bda-ef3d5e434ce7";
|
||||
|
||||
// Path to the event used by MarkdownPreviewHandler
|
||||
const wchar_t SVG_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysSvgPreviewResizeEvent-0701a4fc-d5a1-4ee7-b885-f83982c62a0d";
|
||||
|
||||
// Max DWORD for key code to disable keys.
|
||||
const DWORD VK_DISABLED = 0x100;
|
||||
}
|
||||
|
||||
@@ -58,18 +58,24 @@ bool Logger::wasLogFailedShown()
|
||||
void Logger::init(std::string loggerName, std::wstring logFilePath, std::wstring_view logSettingsPath)
|
||||
{
|
||||
auto logLevel = getLogLevel(logSettingsPath);
|
||||
bool newLoggerCreated = false;
|
||||
try
|
||||
{
|
||||
auto sink = make_shared<daily_file_sink_mt>(logFilePath, 0, 0, false, LogSettings::retention);
|
||||
if (IsDebuggerPresent())
|
||||
logger = spdlog::get(loggerName);
|
||||
if (logger == nullptr)
|
||||
{
|
||||
auto msvc_sink = make_shared<msvc_sink_mt>();
|
||||
msvc_sink->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [%n] [t-%t] [%l] %v");
|
||||
logger = make_shared<spdlog::logger>(loggerName, sinks_init_list{ sink, msvc_sink });
|
||||
}
|
||||
else
|
||||
{
|
||||
logger = make_shared<spdlog::logger>(loggerName, sink);
|
||||
auto sink = make_shared<daily_file_sink_mt>(logFilePath, 0, 0, false, LogSettings::retention);
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
auto msvc_sink = make_shared<msvc_sink_mt>();
|
||||
msvc_sink->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [%n] [t-%t] [%l] %v");
|
||||
logger = make_shared<spdlog::logger>(loggerName, sinks_init_list{ sink, msvc_sink });
|
||||
}
|
||||
else
|
||||
{
|
||||
logger = make_shared<spdlog::logger>(loggerName, sink);
|
||||
}
|
||||
newLoggerCreated = true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
@@ -89,10 +95,14 @@ void Logger::init(std::string loggerName, std::wstring logFilePath, std::wstring
|
||||
return;
|
||||
}
|
||||
|
||||
logger->set_level(logLevel);
|
||||
logger->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [p-%P] [t-%t] [%l] %v");
|
||||
logger->flush_on(logLevel); // Auto flush on every log message.
|
||||
spdlog::register_logger(logger);
|
||||
if (newLoggerCreated)
|
||||
{
|
||||
logger->set_level(logLevel);
|
||||
logger->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [p-%P] [t-%t] [%l] %v");
|
||||
logger->flush_on(logLevel); // Auto flush on every log message.
|
||||
spdlog::register_logger(logger);
|
||||
}
|
||||
|
||||
logger->info("{} logger is initialized", loggerName);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,24 @@ struct LogSettings
|
||||
inline const static std::wstring updateLogPath = L"UpdateLogs\\update-log.txt";
|
||||
inline const static std::string fileExplorerLoggerName = "FileExplorer";
|
||||
inline const static std::wstring fileExplorerLogPath = L"Logs\\file-explorer-log.txt";
|
||||
inline const static std::string gcodePrevLoggerName = "GcodePrevHandler";
|
||||
inline const static std::wstring gcodePrevLogPath = L"logs\\FileExplorer_localLow\\GcodePreviewHandler\\gcode-prev-handler-log.txt";
|
||||
inline const static std::string gcodeThumbLoggerName = "GcodeThumbnailProvider";
|
||||
inline const static std::wstring gcodeThumbLogPath = L"logs\\FileExplorer_localLow\\GcodeThumbnailProvider\\gcode-thumbnail-provider-log.txt";
|
||||
inline const static std::string mdPrevLoggerName = "MDPrevHandler";
|
||||
inline const static std::wstring mdPrevLogPath = L"logs\\FileExplorer_localLow\\MDPrevHandler\\md-prev-handler-log.txt";
|
||||
inline const static std::string monacoPrevLoggerName = "MonacoPrevHandler";
|
||||
inline const static std::wstring monacoPrevLogPath = L"logs\\FileExplorer_localLow\\MonacoPrevHandler\\monaco-prev-handler-log.txt";
|
||||
inline const static std::string pdfPrevLoggerName = "PdfPrevHandler";
|
||||
inline const static std::wstring pdfPrevLogPath = L"logs\\FileExplorer_localLow\\PdfPrevHandler\\pdf-prev-handler-log.txt";
|
||||
inline const static std::string pdfThumbLoggerName = "PdfThumbnailProvider";
|
||||
inline const static std::wstring pdfThumbLogPath = L"logs\\FileExplorer_localLow\\PdfThumbnailProvider\\pdf-thumbnail-provider-log.txt";
|
||||
inline const static std::string stlThumbLoggerName = "StlThumbnailProvider";
|
||||
inline const static std::wstring stlThumbLogPath = L"logs\\FileExplorer_localLow\\StlThumbnailProvider\\stl-thumbnail-provider-log.txt";
|
||||
inline const static std::string svgPrevLoggerName = "SvgPrevHandler";
|
||||
inline const static std::wstring svgPrevLogPath = L"logs\\FileExplorer_localLow\\SvgPrevHandler\\svg-prev-handler-log.txt";
|
||||
inline const static std::string svgThumbLoggerName = "SvgThumbnailProvider";
|
||||
inline const static std::wstring svgThumbLogPath = L"logs\\FileExplorer_localLow\\SvgThumbnailProvider\\svg-thumbnail-provider-log.txt";
|
||||
inline const static std::string launcherLoggerName = "launcher";
|
||||
inline const static std::wstring launcherLogPath = L"LogsModuleInterface\\launcher-log.txt";
|
||||
inline const static std::wstring awakeLogPath = L"Logs\\awake-log.txt";
|
||||
|
||||
@@ -28,13 +28,12 @@ inline registry::ChangeSet getSvgPreviewHandlerChangeSet(const std::wstring inst
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::preview,
|
||||
perUser,
|
||||
L"{ddee2b8a-6807-48a6-bb20-2338174ff779}",
|
||||
L"{FCDD4EED-41AA-492F-8A84-31A1546226E0}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } /
|
||||
LR"d(modules\FileExplorerPreview\PowerToys.SvgPreviewHandler.comhost.dll)d")
|
||||
LR"d(modules\FileExplorerPreview\PowerToys.SvgPreviewHandlerCpp.dll)d")
|
||||
.wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.PreviewHandler.Svg.SvgPreviewHandler",
|
||||
L"SvgPreviewHandler",
|
||||
L"Svg Preview Handler",
|
||||
NonLocalizable::ExtSVG);
|
||||
}
|
||||
@@ -44,11 +43,10 @@ inline registry::ChangeSet getMdPreviewHandlerChangeSet(const std::wstring insta
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::preview,
|
||||
perUser,
|
||||
L"{45769bcc-e8fd-42d0-947e-02beef77a1f5}",
|
||||
L"{60789D87-9C3C-44AF-B18C-3DE2C2820ED3}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.MarkdownPreviewHandler.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.PreviewHandler.Markdown.MarkdownPreviewHandler",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.MarkdownPreviewHandlerCpp.dll)d").wstring(),
|
||||
L"MarkdownPreviewHandler",
|
||||
L"Markdown Preview Handler",
|
||||
NonLocalizable::ExtMarkdown);
|
||||
}
|
||||
@@ -107,11 +105,10 @@ inline registry::ChangeSet getMonacoPreviewHandlerChangeSet(const std::wstring i
|
||||
|
||||
return generatePreviewHandler(PreviewHandlerType::preview,
|
||||
perUser,
|
||||
L"{afbd5a44-2520-4ae0-9224-6cfce8fe4400}",
|
||||
L"{D8034CFA-F34B-41FE-AD45-62FCBB52A6DA}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.MonacoPreviewHandler.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.PreviewHandler.Monaco.MonacoPreviewHandler",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.MonacoPreviewHandlerCpp.dll)d").wstring(),
|
||||
L"MonacoPreviewHandler",
|
||||
L"Monaco Preview Handler",
|
||||
extensions);
|
||||
}
|
||||
@@ -121,11 +118,10 @@ inline registry::ChangeSet getPdfPreviewHandlerChangeSet(const std::wstring inst
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::preview,
|
||||
perUser,
|
||||
L"{07665729-6243-4746-95b7-79579308d1b2}",
|
||||
L"{A5A41CC7-02CB-41D4-8C9B-9087040D6098}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.PdfPreviewHandler.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.PreviewHandler.Pdf.PdfPreviewHandler",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.PdfPreviewHandlerCpp.dll)d").wstring(),
|
||||
L"PdfPreviewHandler",
|
||||
L"Pdf Preview Handler",
|
||||
NonLocalizable::ExtPDF);
|
||||
}
|
||||
@@ -135,11 +131,10 @@ inline registry::ChangeSet getGcodePreviewHandlerChangeSet(const std::wstring in
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::preview,
|
||||
perUser,
|
||||
L"{ec52dea8-7c9f-4130-a77b-1737d0418507}",
|
||||
L"{A0257634-8812-4CE8-AF11-FA69ACAEAFAE}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.GcodePreviewHandler.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.PreviewHandler.Gcode.GcodePreviewHandler",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.GcodePreviewHandlerCpp.dll)d").wstring(),
|
||||
L"GcodePreviewHandler",
|
||||
L"G-code Preview Handler",
|
||||
NonLocalizable::ExtGCode);
|
||||
}
|
||||
@@ -149,11 +144,10 @@ inline registry::ChangeSet getSvgThumbnailHandlerChangeSet(const std::wstring in
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
||||
perUser,
|
||||
L"{36B27788-A8BB-4698-A756-DF9F11F64F84}",
|
||||
L"{10144713-1526-46C9-88DA-1FB52807A9FF}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.SvgThumbnailProvider.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.ThumbnailHandler.Svg.SvgThumbnailProvider",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.SvgThumbnailProviderCpp.dll)d").wstring(),
|
||||
L"SvgThumbnailProvider",
|
||||
L"Svg Thumbnail Provider",
|
||||
NonLocalizable::ExtSVG,
|
||||
L"Picture");
|
||||
@@ -164,11 +158,10 @@ inline registry::ChangeSet getPdfThumbnailHandlerChangeSet(const std::wstring in
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
||||
perUser,
|
||||
L"{BCC13D15-9720-4CC4-8371-EA74A274741E}",
|
||||
L"{D8BB9942-93BD-412D-87E4-33FAB214DC1A}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.PdfThumbnailProvider.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.ThumbnailHandler.Pdf.PdfThumbnailProvider",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.PdfThumbnailProviderCpp.dll)d").wstring(),
|
||||
L"PdfThumbnailProvider",
|
||||
L"Pdf Thumbnail Provider",
|
||||
NonLocalizable::ExtPDF);
|
||||
}
|
||||
@@ -178,11 +171,10 @@ inline registry::ChangeSet getGcodeThumbnailHandlerChangeSet(const std::wstring
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
||||
perUser,
|
||||
L"{BFEE99B4-B74D-4348-BCA5-E757029647FF}",
|
||||
L"{F2847CBE-CD03-4C83-A359-1A8052C1B9D5}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.GcodeThumbnailProvider.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.ThumbnailHandler.Gcode.GcodeThumbnailProvider",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.GcodeThumbnailProviderCpp.dll)d").wstring(),
|
||||
L"GcodeThumbnailProvider",
|
||||
L"G-code Thumbnail Provider",
|
||||
NonLocalizable::ExtGCode);
|
||||
}
|
||||
@@ -192,11 +184,10 @@ inline registry::ChangeSet getStlThumbnailHandlerChangeSet(const std::wstring in
|
||||
using namespace registry::shellex;
|
||||
return generatePreviewHandler(PreviewHandlerType::thumbnail,
|
||||
perUser,
|
||||
L"{8BC8AFC2-4E7C-4695-818E-8C1FFDCEA2AF}",
|
||||
L"{77257004-6F25-4521-B602-50ECC6EC62A6}",
|
||||
get_std_product_version(),
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.StlThumbnailProvider.comhost.dll)d").wstring(),
|
||||
registry::DOTNET_COMPONENT_CATEGORY_CLSID,
|
||||
L"Microsoft.PowerToys.ThumbnailHandler.Stl.StlThumbnailProvider",
|
||||
(fs::path{ installationDir } / LR"d(modules\FileExplorerPreview\PowerToys.StlThumbnailProviderCpp.dll)d").wstring(),
|
||||
L"StlThumbnailProvider",
|
||||
L"Stl Thumbnail Provider",
|
||||
NonLocalizable::ExtSTL);
|
||||
}
|
||||
|
||||
@@ -315,11 +315,10 @@ namespace registry
|
||||
std::wstring handlerClsid,
|
||||
std::wstring powertoysVersion,
|
||||
std::wstring fullPathToHandler,
|
||||
std::wstring handlerCategory,
|
||||
std::wstring className,
|
||||
std::wstring displayName,
|
||||
std::vector<std::wstring> fileTypes,
|
||||
std::wstring fileKindType = L"" )
|
||||
std::wstring fileKindType = L"")
|
||||
{
|
||||
const HKEY scope = perUser ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
|
||||
|
||||
@@ -331,9 +330,6 @@ namespace registry
|
||||
inprocServerPath += L'\\';
|
||||
inprocServerPath += L"InprocServer32";
|
||||
|
||||
std::wstring implementedCategoriesPath = clsidPath + LR"d(\Implemented Categories\)d";
|
||||
implementedCategoriesPath += handlerCategory;
|
||||
|
||||
std::wstring assemblyKeyValue;
|
||||
if (const auto lastDotPos = className.rfind(L'.'); lastDotPos != std::wstring::npos)
|
||||
{
|
||||
@@ -356,13 +352,10 @@ namespace registry
|
||||
// TODO: verify that we actually need all of those
|
||||
vec_t changes = { { scope, clsidPath, L"DisplayName", displayName },
|
||||
{ scope, clsidPath, std::nullopt, className },
|
||||
{ scope, implementedCategoriesPath, std::nullopt, L"" },
|
||||
{ scope, inprocServerPath, std::nullopt, fullPathToHandler },
|
||||
{ scope, inprocServerPath, L"Assembly", assemblyKeyValue },
|
||||
{ scope, inprocServerPath, L"Class", className },
|
||||
{ scope, inprocServerPath, L"ThreadingModel", L"Both" },
|
||||
{ scope, versionPath, L"Assembly", assemblyKeyValue },
|
||||
{ scope, versionPath, L"Class", className } };
|
||||
{ scope, inprocServerPath, L"ThreadingModel", L"Apartment" } };
|
||||
|
||||
for (const auto& fileType : fileTypes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user