Skip to content

Commit

Permalink
Remove inverse dependency on AppInstallerCliCore (microsoft#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft authored Jan 24, 2020
1 parent 9218173 commit 070be16
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 59 deletions.
16 changes: 8 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
Expand All @@ -136,7 +136,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Windows</SubSystem>
Expand All @@ -148,10 +148,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)\Public;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down
12 changes: 6 additions & 6 deletions src/AppInstallerCLICore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace AppInstaller::CLI
{
commandToExecute->OutputHelp(std::cout, &ce);
AICLI_LOG(CLI, Error, << "Error encountered parsing command line: " << ce.Message());
return CLICORE_ERROR_INVALID_CL_ARGUMENTS;
return APPINSTALLER_CLI_ERROR_INVALID_CL_ARGUMENTS;
}

try
Expand All @@ -77,14 +77,14 @@ namespace AppInstaller::CLI
std::string message = Utility::ConvertToUTF8(hre.message());
std::cout << "An error occured while executing the command: " << message << std::endl;
AICLI_LOG(CLI, Error, << "Error encountered executing command: " << message);
return CLICORE_ERROR_COMMAND_FAILED;
return APPINSTALLER_CLI_ERROR_COMMAND_FAILED;
}
catch (const std::exception& e)
{
// TODO: Better error output
std::cout << "An error occured while executing the command: " << e.what() << std::endl;
AICLI_LOG(CLI, Error, << "Error encountered executing command: " << e.what());
return CLICORE_ERROR_COMMAND_FAILED;
return APPINSTALLER_CLI_ERROR_COMMAND_FAILED;
}

return 0;
Expand All @@ -93,15 +93,15 @@ namespace AppInstaller::CLI
// Telemetry cannot be reliable beyond this point, so don't let these happen.
catch (const winrt::hresult_error&)
{
return CLICORE_ERROR_INTERNAL_ERROR;
return APPINSTALLER_CLI_ERROR_INTERNAL_ERROR;
}
catch (const std::exception&)
{
return CLICORE_ERROR_INTERNAL_ERROR;
return APPINSTALLER_CLI_ERROR_INTERNAL_ERROR;
}
catch (...)
{
return CLICORE_ERROR_INTERNAL_ERROR;
return APPINSTALLER_CLI_ERROR_INTERNAL_ERROR;
}

}
11 changes: 0 additions & 11 deletions src/AppInstallerCLICore/Public/AppInstallerCLICore.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@
// Licensed under the MIT License.
#pragma once

#define CLICORE_ERROR_FACILITY 0x8A150000

#define CLICORE_ERROR_INTERNAL_ERROR 0x8A150001
#define CLICORE_ERROR_INVALID_CL_ARGUMENTS 0x8A150002
#define CLICORE_ERROR_COMMAND_FAILED 0x8A150003
#define CLICORE_ERROR_MANIFEST_FAILED 0x8A150004
#define CLICORE_ERROR_WORKFLOW_FAILED 0x8A150005
#define CLICORE_ERROR_INSTALLFLOW_FAILED 0x8A150006
#define CLICORE_ERROR_RUNTIME_ERROR 0x8A150007
#define CLICORE_ERROR_DOWNLOAD_FAILED 0x8A150008

namespace AppInstaller::CLI
{
int CoreMain(int argc, wchar_t const** argv);
Expand Down
12 changes: 6 additions & 6 deletions src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ namespace AppInstaller::Workflow {
if (downloadResult == DownloaderResult::Failed)
{
m_reporter.ShowMsg(WorkflowReporter::Level::Error, "Package download failed.");
THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_INSTALLFLOW_FAILED), "Package download failed");
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED), "Package download failed");
}
else if (downloadResult == DownloaderResult::Canceled)
{
m_reporter.ShowMsg(WorkflowReporter::Level::Info, "Package download canceled.");
THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_INSTALLFLOW_FAILED), "Package download canceled");
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED), "Package download canceled");
}

if (!std::equal(
Expand All @@ -73,7 +73,7 @@ namespace AppInstaller::Workflow {
if (!m_reporter.PromptForBoolResponse(WorkflowReporter::Level::Warning, "Package hash verification failed. Continue?"))
{
m_reporter.ShowMsg(WorkflowReporter::Level::Error, "Canceled. Package hash mismatch.");
THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_INSTALLFLOW_FAILED), "Package installation canceled");
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED), "Package installation canceled");
}
}
else
Expand All @@ -89,7 +89,7 @@ namespace AppInstaller::Workflow {
{
if (m_downloadedInstaller.empty())
{
THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_INSTALLFLOW_FAILED), "Installer not downloaded yet");
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED), "Installer not downloaded yet");
}

m_reporter.ShowMsg(WorkflowReporter::Level::Info, "Installing package ...");
Expand All @@ -106,7 +106,7 @@ namespace AppInstaller::Workflow {
else
{
m_reporter.ShowMsg(WorkflowReporter::Level::Error, "Installer type not supported.");
THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_INSTALLFLOW_FAILED), "Installer type not supported");
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED), "Installer type not supported");
}

m_reporter.ShowIndefiniteSpinner(true);
Expand All @@ -121,7 +121,7 @@ namespace AppInstaller::Workflow {
{
m_reporter.ShowMsg(WorkflowReporter::Level::Error, "Install failed. Exit code: " + std::to_string(installResult));

THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_INSTALLFLOW_FAILED),
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED),
"Install failed. Installer task returned: %u", installResult);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/ManifestComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace AppInstaller::Workflow
if (Utility::IsApplicableArchitecture(m_manifestRef.Installers[0].Arch) == -1)
{
m_reporterRef.ShowMsg(WorkflowReporter::Level::Error, "No applicable installer found.");
THROW_EXCEPTION_MSG(WorkflowException(CLICORE_ERROR_WORKFLOW_FAILED), "No installer with applicable architecture found.");
THROW_EXCEPTION_MSG(WorkflowException(APPINSTALLER_CLI_ERROR_WORKFLOW_FAILED), "No installer with applicable architecture found.");
}

ManifestInstaller selectedInstaller = m_manifestRef.Installers[0];
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
#include "AppInstallerRuntime.h"
#include "AppInstallerSHA256.h"
#include "AppInstallerDownloader.h"
#include "AppInstallerErrors.h"
#include "Manifest/ManifestInstaller.h"
#include "Manifest/Manifest.h"
17 changes: 9 additions & 8 deletions src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
Expand All @@ -136,7 +136,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Windows</SubSystem>
Expand All @@ -148,10 +148,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)Telemetry;$(ProjectDir)..\AppInstallerCliCore\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)Telemetry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -168,6 +168,7 @@
<ClInclude Include="FileLogger.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="Public\AppInstallerDownloader.h" />
<ClInclude Include="Public\AppInstallerErrors.h" />
<ClInclude Include="Public\AppInstallerRuntime.h" />
<ClInclude Include="Public\AppInstallerSHA256.h" />
<ClInclude Include="Public\AppInstallerStrings.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<ClInclude Include="Public\AppInstallerArchitecture.h">
<Filter>Public</Filter>
</ClInclude>
<ClInclude Include="Public\AppInstallerErrors.h">
<Filter>Public</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down
15 changes: 15 additions & 0 deletions src/AppInstallerCommonCore/Public/AppInstallerErrors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#pragma once

#define APPINSTALLER_CLI_ERROR_FACILITY 0x8A150000

#define APPINSTALLER_CLI_ERROR_INTERNAL_ERROR 0x8A150001
#define APPINSTALLER_CLI_ERROR_INVALID_CL_ARGUMENTS 0x8A150002
#define APPINSTALLER_CLI_ERROR_COMMAND_FAILED 0x8A150003
#define APPINSTALLER_CLI_ERROR_MANIFEST_FAILED 0x8A150004
#define APPINSTALLER_CLI_ERROR_WORKFLOW_FAILED 0x8A150005
#define APPINSTALLER_CLI_ERROR_INSTALLFLOW_FAILED 0x8A150006
#define APPINSTALLER_CLI_ERROR_RUNTIME_ERROR 0x8A150007
#define APPINSTALLER_CLI_ERROR_DOWNLOAD_FAILED 0x8A150008
1 change: 0 additions & 1 deletion src/AppInstallerCommonCore/Public/AppInstallerRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.
#pragma once
#include "AppInstallerArchitecture.h"
#include "AppInstallerCLICore.h"

#include <filesystem>
#include <string>
Expand Down
Loading

0 comments on commit 070be16

Please sign in to comment.