From 6532872c4f81daf8c6c7eecc2b8c6842a3880941 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Fri, 6 Dec 2019 17:04:14 -0800 Subject: [PATCH 1/4] Move code into a DLL, but VS not copying it to output yet --- src/AppInstallerCLI/AppInstallerCLI.vcxproj | 43 ++-- .../AppInstallerCLI.vcxproj.filters | 45 ---- src/AppInstallerCLI/main.cpp | 58 +----- .../AppInstallerCLICore.vcxproj | 194 ++++++++++++++++++ .../AppInstallerCLICore.vcxproj.filters | 79 +++++++ .../Command.cpp | 0 .../Command.h | 0 .../Commands/DescribeCommand.cpp | 0 .../Commands/DescribeCommand.h | 0 .../Commands/InstallCommand.cpp | 0 .../Commands/InstallCommand.h | 0 .../Commands/RootCommand.cpp | 0 .../Commands/RootCommand.h | 0 .../Common.h | 0 src/AppInstallerCLICore/Exports.cpp | 68 ++++++ .../Invocation.h | 0 .../Localization.h | 0 src/AppInstallerCLICore/PropertySheet.props | 16 ++ .../Public/AppInstallerCLICore.h | 19 ++ .../Search/Search.h | 0 .../packages.config | 0 .../pch.cpp | 0 .../pch.h | 0 src/AppInstallerClient.sln | 178 +++++++++------- .../AppInstallerClientPackage.wapproj | 154 +++++++------- 25 files changed, 570 insertions(+), 284 deletions(-) create mode 100644 src/AppInstallerCLICore/AppInstallerCLICore.vcxproj create mode 100644 src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters rename src/{AppInstallerCLI => AppInstallerCLICore}/Command.cpp (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Command.h (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Commands/DescribeCommand.cpp (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Commands/DescribeCommand.h (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Commands/InstallCommand.cpp (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Commands/InstallCommand.h (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Commands/RootCommand.cpp (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Commands/RootCommand.h (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Common.h (100%) create mode 100644 src/AppInstallerCLICore/Exports.cpp rename src/{AppInstallerCLI => AppInstallerCLICore}/Invocation.h (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/Localization.h (100%) create mode 100644 src/AppInstallerCLICore/PropertySheet.props create mode 100644 src/AppInstallerCLICore/Public/AppInstallerCLICore.h rename src/{AppInstallerCLI => AppInstallerCLICore}/Search/Search.h (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/packages.config (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/pch.cpp (100%) rename src/{AppInstallerCLI => AppInstallerCLICore}/pch.h (100%) diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj b/src/AppInstallerCLI/AppInstallerCLI.vcxproj index e65294e371..35dc9659d5 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj @@ -111,7 +111,7 @@ - Use + NotUsing pch.h $(IntDir)pch.pch _CONSOLE;%(PreprocessorDefinitions) @@ -123,9 +123,9 @@ Disabled _DEBUG;%(PreprocessorDefinitions) - $(ProjectDir);%(AdditionalIncludeDirectories) - $(ProjectDir);%(AdditionalIncludeDirectories) - $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) Console @@ -135,7 +135,7 @@ WIN32;%(PreprocessorDefinitions) - $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) @@ -144,10 +144,10 @@ true true NDEBUG;%(PreprocessorDefinitions) - $(ProjectDir);%(AdditionalIncludeDirectories) - $(ProjectDir);%(AdditionalIncludeDirectories) - $(ProjectDir);%(AdditionalIncludeDirectories) - $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir);$(SolutionDir)AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) Console @@ -157,30 +157,17 @@ - - - - - - - - - - - - - - - - - Create - - + + + {1c6e0108-2860-4b17-9f7e-fa5c6c1f3d3d} + true + + diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj.filters b/src/AppInstallerCLI/AppInstallerCLI.vcxproj.filters index 2b82f16c7b..dac8cb8e1c 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj.filters +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj.filters @@ -18,56 +18,11 @@ - - Header Files - - - Commands - - - Header Files - - - Commands - - - Commands - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - Source Files - - Commands - - - Commands - - - Commands - - - Source Files - - \ No newline at end of file diff --git a/src/AppInstallerCLI/main.cpp b/src/AppInstallerCLI/main.cpp index 8d60f50748..98ca1c1711 100644 --- a/src/AppInstallerCLI/main.cpp +++ b/src/AppInstallerCLI/main.cpp @@ -1,60 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#include "pch.h" -#include "Commands/RootCommand.h" +#include -using namespace winrt; -using namespace Windows::Foundation; -using namespace AppInstaller::CLI; - -int wmain(int argc, wchar_t const** argv) try +int wmain(int argc, wchar_t const** argv) { - init_apartment(); - - RootCommand root; - Invocation invocation{ argc, argv }; - - // The root command is our fallback in the event of very bad or very little input - Command* commandToExecute = &root; - std::unique_ptr foundCommand; - - try - { - foundCommand = root.FindInvokedCommand(invocation); - if (foundCommand) - { - commandToExecute = foundCommand.get(); - } - commandToExecute->ParseArguments(invocation); - commandToExecute->ValidateArguments(invocation); - } - // Exceptions specific to parsing the arguments of a command - catch (const CommandException& ce) - { - commandToExecute->OutputHelp(std::wcout, &ce); - return 1; - } - - try - { - commandToExecute->Execute(invocation, std::wcout); - } - // Exceptions that may occur in the process of executing an arbitrary command - catch (const winrt::hresult_error&) - { - - } - catch (const std::exception&) - { - - } -} -// End of the line exceptions that are not ever expected -catch (const winrt::hresult_error&) -{ - -} -catch (const std::exception&) -{ - + return CLICoreMain(argc, argv); } diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj new file mode 100644 index 0000000000..687532b5ae --- /dev/null +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -0,0 +1,194 @@ + + + + + true + true + true + 15.0 + {1c6e0108-2860-4b17-9f7e-fa5c6c1f3d3d} + Win32Proj + AppInstallerCLICore + 10.0.18362.0 + 10.0.16299.0 + true + true + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + DynamicLibrary + v140 + v141 + v142 + Unicode + + + true + true + + + false + true + false + + + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + + + true + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + + + true + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + + + true + $(SolutionDir)x86\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)x86\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + + + + Use + pch.h + $(IntDir)pch.pch + _CONSOLE;%(PreprocessorDefinitions) + Level4 + %(AdditionalOptions) /permissive- /bigobj + + + + + Disabled + _DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD + $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);%(AdditionalIncludeDirectories) + + + false + + + + + WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD + $(ProjectDir);%(AdditionalIncludeDirectories) + + + + + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD + $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);%(AdditionalIncludeDirectories) + $(ProjectDir);%(AdditionalIncludeDirectories) + + + true + true + false + + + + + + + + + + + + + + + + + + + + + + Create + + + + + + + + + + + + + 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/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters new file mode 100644 index 0000000000..41ac88c98f --- /dev/null +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -0,0 +1,79 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {4b0dcf8b-b4a1-47e5-9c28-e8a3440178e6} + + + {00cc3138-2893-4fc4-8595-d3cf9d26be1c} + + + + + Header Files + + + Commands + + + Header Files + + + Commands + + + Commands + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Public + + + + + Source Files + + + Source Files + + + Commands + + + Commands + + + Commands + + + Source Files + + + + + + + \ No newline at end of file diff --git a/src/AppInstallerCLI/Command.cpp b/src/AppInstallerCLICore/Command.cpp similarity index 100% rename from src/AppInstallerCLI/Command.cpp rename to src/AppInstallerCLICore/Command.cpp diff --git a/src/AppInstallerCLI/Command.h b/src/AppInstallerCLICore/Command.h similarity index 100% rename from src/AppInstallerCLI/Command.h rename to src/AppInstallerCLICore/Command.h diff --git a/src/AppInstallerCLI/Commands/DescribeCommand.cpp b/src/AppInstallerCLICore/Commands/DescribeCommand.cpp similarity index 100% rename from src/AppInstallerCLI/Commands/DescribeCommand.cpp rename to src/AppInstallerCLICore/Commands/DescribeCommand.cpp diff --git a/src/AppInstallerCLI/Commands/DescribeCommand.h b/src/AppInstallerCLICore/Commands/DescribeCommand.h similarity index 100% rename from src/AppInstallerCLI/Commands/DescribeCommand.h rename to src/AppInstallerCLICore/Commands/DescribeCommand.h diff --git a/src/AppInstallerCLI/Commands/InstallCommand.cpp b/src/AppInstallerCLICore/Commands/InstallCommand.cpp similarity index 100% rename from src/AppInstallerCLI/Commands/InstallCommand.cpp rename to src/AppInstallerCLICore/Commands/InstallCommand.cpp diff --git a/src/AppInstallerCLI/Commands/InstallCommand.h b/src/AppInstallerCLICore/Commands/InstallCommand.h similarity index 100% rename from src/AppInstallerCLI/Commands/InstallCommand.h rename to src/AppInstallerCLICore/Commands/InstallCommand.h diff --git a/src/AppInstallerCLI/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp similarity index 100% rename from src/AppInstallerCLI/Commands/RootCommand.cpp rename to src/AppInstallerCLICore/Commands/RootCommand.cpp diff --git a/src/AppInstallerCLI/Commands/RootCommand.h b/src/AppInstallerCLICore/Commands/RootCommand.h similarity index 100% rename from src/AppInstallerCLI/Commands/RootCommand.h rename to src/AppInstallerCLICore/Commands/RootCommand.h diff --git a/src/AppInstallerCLI/Common.h b/src/AppInstallerCLICore/Common.h similarity index 100% rename from src/AppInstallerCLI/Common.h rename to src/AppInstallerCLICore/Common.h diff --git a/src/AppInstallerCLICore/Exports.cpp b/src/AppInstallerCLICore/Exports.cpp new file mode 100644 index 0000000000..84305fd7e9 --- /dev/null +++ b/src/AppInstallerCLICore/Exports.cpp @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "Public/AppInstallerCLICore.h" +#include "Commands/RootCommand.h" + +using namespace winrt; +using namespace Windows::Foundation; +using namespace AppInstaller::CLI; + +extern "C" +{ + + CLICOREAPIEXPORT int CLICoreMain(int argc, wchar_t const** argv) try + { + init_apartment(); + + RootCommand root; + Invocation invocation{ argc, argv }; + + // The root command is our fallback in the event of very bad or very little input + Command* commandToExecute = &root; + std::unique_ptr foundCommand; + + try + { + foundCommand = root.FindInvokedCommand(invocation); + if (foundCommand) + { + commandToExecute = foundCommand.get(); + } + commandToExecute->ParseArguments(invocation); + commandToExecute->ValidateArguments(invocation); + } + // Exceptions specific to parsing the arguments of a command + catch (const CommandException& ce) + { + commandToExecute->OutputHelp(std::wcout, &ce); + return CLICORE_ERROR_INVALID_CL_ARGUMENTS; + } + + try + { + commandToExecute->Execute(invocation, std::wcout); + } + // Exceptions that may occur in the process of executing an arbitrary command + catch (const winrt::hresult_error&) + { + + } + catch (const std::exception&) + { + + } + + return 0; + } + // End of the line exceptions that are not ever expected + catch (const winrt::hresult_error&) + { + return CLICORE_ERROR_INTERNAL_ERROR; + } + catch (const std::exception&) + { + return CLICORE_ERROR_INTERNAL_ERROR; + } + +} diff --git a/src/AppInstallerCLI/Invocation.h b/src/AppInstallerCLICore/Invocation.h similarity index 100% rename from src/AppInstallerCLI/Invocation.h rename to src/AppInstallerCLICore/Invocation.h diff --git a/src/AppInstallerCLI/Localization.h b/src/AppInstallerCLICore/Localization.h similarity index 100% rename from src/AppInstallerCLI/Localization.h rename to src/AppInstallerCLICore/Localization.h diff --git a/src/AppInstallerCLICore/PropertySheet.props b/src/AppInstallerCLICore/PropertySheet.props new file mode 100644 index 0000000000..c6b0691ddd --- /dev/null +++ b/src/AppInstallerCLICore/PropertySheet.props @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h new file mode 100644 index 0000000000..c418329329 --- /dev/null +++ b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once + +#ifdef CLICOREDLLBUILD + #define CLICOREAPIEXPORT __declspec(dllexport) +#else + #define CLICOREAPIEXPORT __declspec(dllimport) +#endif + +#define CLICORE_ERROR_FACILITY 0x8A150000 + +#define CLICORE_ERROR_INVALID_CL_ARGUMENTS 0x8A150001 +#define CLICORE_ERROR_INTERNAL_ERROR 0x8A150002 + +extern "C" +{ + CLICOREAPIEXPORT int CLICoreMain(int argc, wchar_t const** argv); +} diff --git a/src/AppInstallerCLI/Search/Search.h b/src/AppInstallerCLICore/Search/Search.h similarity index 100% rename from src/AppInstallerCLI/Search/Search.h rename to src/AppInstallerCLICore/Search/Search.h diff --git a/src/AppInstallerCLI/packages.config b/src/AppInstallerCLICore/packages.config similarity index 100% rename from src/AppInstallerCLI/packages.config rename to src/AppInstallerCLICore/packages.config diff --git a/src/AppInstallerCLI/pch.cpp b/src/AppInstallerCLICore/pch.cpp similarity index 100% rename from src/AppInstallerCLI/pch.cpp rename to src/AppInstallerCLICore/pch.cpp diff --git a/src/AppInstallerCLI/pch.h b/src/AppInstallerCLICore/pch.h similarity index 100% rename from src/AppInstallerCLI/pch.h rename to src/AppInstallerCLICore/pch.h diff --git a/src/AppInstallerClient.sln b/src/AppInstallerClient.sln index 42b13737cf..fe556b781a 100644 --- a/src/AppInstallerClient.sln +++ b/src/AppInstallerClient.sln @@ -1,79 +1,99 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29409.12 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "AppInstallerClientPackage", "AppInstallerClientPackage\AppInstallerClientPackage.wapproj", "{6AA3791A-0713-4548-A357-87A323E7AC3A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInstallerCLI", "AppInstallerCLI\AppInstallerCLI.vcxproj", "{5B6F90DF-FD19-4BAE-83D9-24DAD128E777}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM.ActiveCfg = Debug|ARM - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM.Build.0 = Debug|ARM - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM.Deploy.0 = Debug|ARM - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM64.Build.0 = Debug|ARM64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x64.ActiveCfg = Debug|x64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x64.Build.0 = Debug|x64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x64.Deploy.0 = Debug|x64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x86.ActiveCfg = Debug|x86 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x86.Build.0 = Debug|x86 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x86.Deploy.0 = Debug|x86 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|Any CPU.Build.0 = Release|Any CPU - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|Any CPU.Deploy.0 = Release|Any CPU - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM.ActiveCfg = Release|ARM - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM.Build.0 = Release|ARM - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM.Deploy.0 = Release|ARM - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM64.ActiveCfg = Release|ARM64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM64.Build.0 = Release|ARM64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM64.Deploy.0 = Release|ARM64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x64.ActiveCfg = Release|x64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x64.Build.0 = Release|x64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x64.Deploy.0 = Release|x64 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x86.ActiveCfg = Release|x86 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x86.Build.0 = Release|x86 - {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x86.Deploy.0 = Release|x86 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM.ActiveCfg = Debug|ARM - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM.Build.0 = Debug|ARM - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM64.Build.0 = Debug|ARM64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x64.ActiveCfg = Debug|x64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x64.Build.0 = Debug|x64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x86.ActiveCfg = Debug|Win32 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x86.Build.0 = Debug|Win32 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|Any CPU.ActiveCfg = Release|Win32 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM.ActiveCfg = Release|ARM - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM.Build.0 = Release|ARM - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM64.ActiveCfg = Release|ARM64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM64.Build.0 = Release|ARM64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x64.ActiveCfg = Release|x64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x64.Build.0 = Release|x64 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x86.ActiveCfg = Release|Win32 - {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B6FDB70C-A751-422C-ACD1-E35419495857} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29409.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "AppInstallerClientPackage", "AppInstallerClientPackage\AppInstallerClientPackage.wapproj", "{6AA3791A-0713-4548-A357-87A323E7AC3A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInstallerCLI", "AppInstallerCLI\AppInstallerCLI.vcxproj", "{5B6F90DF-FD19-4BAE-83D9-24DAD128E777}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInstallerCLICore", "AppInstallerCLICore\AppInstallerCLICore.vcxproj", "{1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM.ActiveCfg = Debug|ARM + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM.Build.0 = Debug|ARM + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM.Deploy.0 = Debug|ARM + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM64.Build.0 = Debug|ARM64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x64.ActiveCfg = Debug|x64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x64.Build.0 = Debug|x64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x64.Deploy.0 = Debug|x64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x86.ActiveCfg = Debug|x86 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x86.Build.0 = Debug|x86 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Debug|x86.Deploy.0 = Debug|x86 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|Any CPU.Build.0 = Release|Any CPU + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|Any CPU.Deploy.0 = Release|Any CPU + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM.ActiveCfg = Release|ARM + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM.Build.0 = Release|ARM + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM.Deploy.0 = Release|ARM + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM64.ActiveCfg = Release|ARM64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM64.Build.0 = Release|ARM64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|ARM64.Deploy.0 = Release|ARM64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x64.ActiveCfg = Release|x64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x64.Build.0 = Release|x64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x64.Deploy.0 = Release|x64 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x86.ActiveCfg = Release|x86 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x86.Build.0 = Release|x86 + {6AA3791A-0713-4548-A357-87A323E7AC3A}.Release|x86.Deploy.0 = Release|x86 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM.ActiveCfg = Debug|ARM + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM.Build.0 = Debug|ARM + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|ARM64.Build.0 = Debug|ARM64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x64.ActiveCfg = Debug|x64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x64.Build.0 = Debug|x64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x86.ActiveCfg = Debug|Win32 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Debug|x86.Build.0 = Debug|Win32 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|Any CPU.ActiveCfg = Release|Win32 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM.ActiveCfg = Release|ARM + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM.Build.0 = Release|ARM + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM64.ActiveCfg = Release|ARM64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|ARM64.Build.0 = Release|ARM64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x64.ActiveCfg = Release|x64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x64.Build.0 = Release|x64 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x86.ActiveCfg = Release|Win32 + {5B6F90DF-FD19-4BAE-83D9-24DAD128E777}.Release|x86.Build.0 = Release|Win32 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|ARM.ActiveCfg = Debug|ARM + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|ARM.Build.0 = Debug|ARM + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|ARM64.Build.0 = Debug|ARM64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|x64.ActiveCfg = Debug|x64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|x64.Build.0 = Debug|x64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|x86.ActiveCfg = Debug|Win32 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Debug|x86.Build.0 = Debug|Win32 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|Any CPU.ActiveCfg = Release|Win32 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|ARM.ActiveCfg = Release|ARM + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|ARM.Build.0 = Release|ARM + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|ARM64.ActiveCfg = Release|ARM64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|ARM64.Build.0 = Release|ARM64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|x64.ActiveCfg = Release|x64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|x64.Build.0 = Release|x64 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|x86.ActiveCfg = Release|Win32 + {1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B6FDB70C-A751-422C-ACD1-E35419495857} + EndGlobalSection +EndGlobal diff --git a/src/AppInstallerClientPackage/AppInstallerClientPackage.wapproj b/src/AppInstallerClientPackage/AppInstallerClientPackage.wapproj index e1dd2c75d0..0d5d2b6907 100644 --- a/src/AppInstallerClientPackage/AppInstallerClientPackage.wapproj +++ b/src/AppInstallerClientPackage/AppInstallerClientPackage.wapproj @@ -1,78 +1,78 @@ - - - - 15.0 - - - - Debug - x86 - - - Release - x86 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - Debug - ARM64 - - - Release - ARM64 - - - Debug - AnyCPU - - - Release - AnyCPU - - - - $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ - - - - 6aa3791a-0713-4548-a357-87a323e7ac3a - 10.0.18362.0 - 10.0.16299.0 - en-US - false - ..\AppInstallerCLI\AppInstallerCLI.vcxproj - - - - Designer - - - - - - - - - - - - - - - + + + + 15.0 + + + + Debug + x86 + + + Release + x86 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + AnyCPU + + + Release + AnyCPU + + + + $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ + + + + 6aa3791a-0713-4548-a357-87a323e7ac3a + 10.0.18362.0 + 10.0.16299.0 + en-US + false + ..\AppInstallerCLI\AppInstallerCLI.vcxproj + + + + Designer + + + + + + + + + + + + + + + \ No newline at end of file From 21b323bf88426ac4bee64036037d3f56853a7b42 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Mon, 9 Dec 2019 16:22:30 -0800 Subject: [PATCH 2/4] Make Core a lib rather than a dll. --- src/AppInstallerCLI/AppInstallerCLI.vcxproj | 2 +- .../AppInstallerCLICore.vcxproj | 14 +++- .../AppInstallerCLICore.vcxproj.filters | 6 +- src/AppInstallerCLICore/Core.cpp | 63 +++++++++++++++++ src/AppInstallerCLICore/Exports.cpp | 68 ------------------- .../Public/AppInstallerCLICore.h | 11 +-- .../Package.appxmanifest | 2 +- 7 files changed, 81 insertions(+), 85 deletions(-) create mode 100644 src/AppInstallerCLICore/Core.cpp delete mode 100644 src/AppInstallerCLICore/Exports.cpp diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj b/src/AppInstallerCLI/AppInstallerCLI.vcxproj index 35dc9659d5..24931ec5d8 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj @@ -165,7 +165,7 @@ {1c6e0108-2860-4b17-9f7e-fa5c6c1f3d3d} - true + false diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 687532b5ae..d3fa30d0b3 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -50,7 +50,7 @@ - DynamicLibrary + StaticLibrary v140 v141 v142 @@ -129,6 +129,9 @@ false + Windows + Windows + Windows @@ -136,6 +139,9 @@ WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD $(ProjectDir);%(AdditionalIncludeDirectories) + + Windows + @@ -152,6 +158,10 @@ true true false + Windows + Windows + Windows + Windows @@ -171,7 +181,7 @@ - + Create diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 41ac88c98f..1d37dbb452 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -56,9 +56,6 @@ Source Files - - Source Files - Commands @@ -71,6 +68,9 @@ Source Files + + Source Files + diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp new file mode 100644 index 0000000000..7966e722f6 --- /dev/null +++ b/src/AppInstallerCLICore/Core.cpp @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "Public/AppInstallerCLICore.h" +#include "Commands/RootCommand.h" + +using namespace winrt; +using namespace Windows::Foundation; +using namespace AppInstaller::CLI; + +int CLICoreMain(int argc, wchar_t const** argv) try +{ + init_apartment(); + + RootCommand root; + Invocation invocation{ argc, argv }; + + // The root command is our fallback in the event of very bad or very little input + Command* commandToExecute = &root; + std::unique_ptr foundCommand; + + try + { + foundCommand = root.FindInvokedCommand(invocation); + if (foundCommand) + { + commandToExecute = foundCommand.get(); + } + commandToExecute->ParseArguments(invocation); + commandToExecute->ValidateArguments(invocation); + } + // Exceptions specific to parsing the arguments of a command + catch (const CommandException& ce) + { + commandToExecute->OutputHelp(std::wcout, &ce); + return CLICORE_ERROR_INVALID_CL_ARGUMENTS; + } + + try + { + commandToExecute->Execute(invocation, std::wcout); + } + // Exceptions that may occur in the process of executing an arbitrary command + catch (const winrt::hresult_error&) + { + + } + catch (const std::exception&) + { + + } + + return 0; +} +// End of the line exceptions that are not ever expected +catch (const winrt::hresult_error&) +{ + return CLICORE_ERROR_INTERNAL_ERROR; +} +catch (const std::exception&) +{ + return CLICORE_ERROR_INTERNAL_ERROR; +} diff --git a/src/AppInstallerCLICore/Exports.cpp b/src/AppInstallerCLICore/Exports.cpp deleted file mode 100644 index 84305fd7e9..0000000000 --- a/src/AppInstallerCLICore/Exports.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#include "pch.h" -#include "Public/AppInstallerCLICore.h" -#include "Commands/RootCommand.h" - -using namespace winrt; -using namespace Windows::Foundation; -using namespace AppInstaller::CLI; - -extern "C" -{ - - CLICOREAPIEXPORT int CLICoreMain(int argc, wchar_t const** argv) try - { - init_apartment(); - - RootCommand root; - Invocation invocation{ argc, argv }; - - // The root command is our fallback in the event of very bad or very little input - Command* commandToExecute = &root; - std::unique_ptr foundCommand; - - try - { - foundCommand = root.FindInvokedCommand(invocation); - if (foundCommand) - { - commandToExecute = foundCommand.get(); - } - commandToExecute->ParseArguments(invocation); - commandToExecute->ValidateArguments(invocation); - } - // Exceptions specific to parsing the arguments of a command - catch (const CommandException& ce) - { - commandToExecute->OutputHelp(std::wcout, &ce); - return CLICORE_ERROR_INVALID_CL_ARGUMENTS; - } - - try - { - commandToExecute->Execute(invocation, std::wcout); - } - // Exceptions that may occur in the process of executing an arbitrary command - catch (const winrt::hresult_error&) - { - - } - catch (const std::exception&) - { - - } - - return 0; - } - // End of the line exceptions that are not ever expected - catch (const winrt::hresult_error&) - { - return CLICORE_ERROR_INTERNAL_ERROR; - } - catch (const std::exception&) - { - return CLICORE_ERROR_INTERNAL_ERROR; - } - -} diff --git a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h index c418329329..ea3c3dff9a 100644 --- a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h +++ b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h @@ -2,18 +2,9 @@ // Licensed under the MIT License. #pragma once -#ifdef CLICOREDLLBUILD - #define CLICOREAPIEXPORT __declspec(dllexport) -#else - #define CLICOREAPIEXPORT __declspec(dllimport) -#endif - #define CLICORE_ERROR_FACILITY 0x8A150000 #define CLICORE_ERROR_INVALID_CL_ARGUMENTS 0x8A150001 #define CLICORE_ERROR_INTERNAL_ERROR 0x8A150002 -extern "C" -{ - CLICOREAPIEXPORT int CLICoreMain(int argc, wchar_t const** argv); -} +int CLICoreMain(int argc, wchar_t const** argv); diff --git a/src/AppInstallerClientPackage/Package.appxmanifest b/src/AppInstallerClientPackage/Package.appxmanifest index 89cf68155c..1064864532 100644 --- a/src/AppInstallerClientPackage/Package.appxmanifest +++ b/src/AppInstallerClientPackage/Package.appxmanifest @@ -8,7 +8,7 @@ xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap uap5 uap8 wincap rescap desktop"> - + App Installer Client Microsoft Corporation From 5b80d7995f7714be1de646b2cfef331a958f9624 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Mon, 9 Dec 2019 17:05:40 -0800 Subject: [PATCH 3/4] Move telemetry reference to Core lib. --- src/AppInstallerCLI/AppInstallerCLI.vcxproj | 1 - .../AppInstallerCLICore.vcxproj | 1 + src/AppInstallerClient.sln | 23 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj b/src/AppInstallerCLI/AppInstallerCLI.vcxproj index 3f19883788..24931ec5d8 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj @@ -69,7 +69,6 @@ - diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index d3fa30d0b3..24e3099ccf 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -69,6 +69,7 @@ + diff --git a/src/AppInstallerClient.sln b/src/AppInstallerClient.sln index f093bca243..32431d3e51 100644 --- a/src/AppInstallerClient.sln +++ b/src/AppInstallerClient.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29409.12 @@ -8,15 +7,15 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInstallerCLI", "AppInstallerCLI\AppInstallerCLI.vcxproj", "{5B6F90DF-FD19-4BAE-83D9-24DAD128E777}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppInstallerCLICore", "AppInstallerCLICore\AppInstallerCLICore.vcxproj", "{1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{60618CAC-2995-4DF9-9914-45C6FC02C995}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Telemetry", "Telemetry\Telemetry.vcxitems", "{4B988559-DDBD-4456-9300-0C3AAD12C466}" EndProject -Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - Telemetry\Telemetry.vcxitems*{4b988559-ddbd-4456-9300-0c3aad12c466}*SharedItemsImports = 9 - Telemetry\Telemetry.vcxitems*{5b6f90df-fd19-4bae-83d9-24dad128e777}*SharedItemsImports = 4 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{60618CAC-2995-4DF9-9914-45C6FC02C995}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Telemetry", "Telemetry\Telemetry.vcxitems", "{4B988559-DDBD-4456-9300-0C3AAD12C466}" +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + Telemetry\Telemetry.vcxitems*{1c6e0108-2860-4b17-9f7e-fa5c6c1f3d3d}*SharedItemsImports = 4 + Telemetry\Telemetry.vcxitems*{4b988559-ddbd-4456-9300-0c3aad12c466}*SharedItemsImports = 9 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -100,9 +99,9 @@ Global EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {4B988559-DDBD-4456-9300-0C3AAD12C466} = {60618CAC-2995-4DF9-9914-45C6FC02C995} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {4B988559-DDBD-4456-9300-0C3AAD12C466} = {60618CAC-2995-4DF9-9914-45C6FC02C995} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B6FDB70C-A751-422C-ACD1-E35419495857} From 31deb3904ad529b9829056b7349d727f819bd71b Mon Sep 17 00:00:00 2001 From: John McPherson Date: Tue, 10 Dec 2019 10:56:50 -0800 Subject: [PATCH 4/4] Create RAII telemetry registration. --- src/AppInstallerCLICore/Core.cpp | 5 ++-- src/AppInstallerCLICore/pch.h | 6 ++-- src/Telemetry/Telemetry.vcxitems | 47 ++++++++++++++++---------------- src/Telemetry/TelemetryWrapper.h | 20 ++++++++++++++ 4 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 src/Telemetry/TelemetryWrapper.h diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index ca02c31e5e..5aec309d97 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -11,7 +11,7 @@ using namespace AppInstaller::CLI; int CLICoreMain(int argc, wchar_t const** argv) try { init_apartment(); - RegisterTraceLogging(); + TraceLoggingRegistration tlRegistration; RootCommand root; Invocation invocation{ argc, argv }; @@ -53,7 +53,8 @@ int CLICoreMain(int argc, wchar_t const** argv) try return 0; } -// End of the line exceptions that are not ever expected +// End of the line exceptions that are not ever expected. +// Telemetry cannot be reliable beyond this point, so don't let these happen. catch (const winrt::hresult_error&) { return CLICORE_ERROR_INTERNAL_ERROR; diff --git a/src/AppInstallerCLICore/pch.h b/src/AppInstallerCLICore/pch.h index 41212a32f3..276c40c81d 100644 --- a/src/AppInstallerCLICore/pch.h +++ b/src/AppInstallerCLICore/pch.h @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #pragma once + +#include +#include "TelemetryWrapper.h" + #include #include #include #include -#include -#include "TraceLogging.h" diff --git a/src/Telemetry/Telemetry.vcxitems b/src/Telemetry/Telemetry.vcxitems index 12788fc320..300476c5e1 100644 --- a/src/Telemetry/Telemetry.vcxitems +++ b/src/Telemetry/Telemetry.vcxitems @@ -1,24 +1,25 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {4b988559-ddbd-4456-9300-0c3aad12c466} - - - - %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) - - - - - - - - - - - - - + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {4b988559-ddbd-4456-9300-0c3aad12c466} + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Telemetry/TelemetryWrapper.h b/src/Telemetry/TelemetryWrapper.h new file mode 100644 index 0000000000..e694aa9b96 --- /dev/null +++ b/src/Telemetry/TelemetryWrapper.h @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once + +#include +#include "TraceLogging.h" + +struct TraceLoggingRegistration +{ + TraceLoggingRegistration() + { + RegisterTraceLogging(); + } + + ~TraceLoggingRegistration() + { + UnRegisterTraceLogging(); + } +}; +