|
5 | 5 | #include "ImportExportFlow.h" |
6 | 6 | #include "PromptFlow.h" |
7 | 7 | #include "TableOutput.h" |
| 8 | +#include "MSStoreInstallerHandler.h" |
8 | 9 | #include "Public/ConfigurationSetProcessorFactoryRemoting.h" |
9 | 10 | #include "ConfigurationCommon.h" |
10 | 11 | #include "ConfigurationWingetDscModuleUnitValidation.h" |
@@ -187,6 +188,41 @@ namespace AppInstaller::CLI::Workflow |
187 | 188 | { |
188 | 189 | factoryMap.Insert(ConfigurationRemoting::ToHString(ConfigurationRemoting::PropertyName::DscExecutablePath), Utility::ConvertToUTF16(context.Args.GetArg(Args::Type::ConfigurationProcessorPath))); |
189 | 190 | } |
| 191 | + else |
| 192 | + { |
| 193 | + // Make sure DSC executable path can be found. Otherwise, we'll install the DSC v3 package. |
| 194 | + winrt::hstring foundExecutablePath = factoryMap.Lookup(ConfigurationRemoting::ToHString(ConfigurationRemoting::PropertyName::FoundDscExecutablePath)); |
| 195 | + if (foundExecutablePath.empty()) |
| 196 | + { |
| 197 | + AICLI_LOG(Config, Info, << "dsc.exe not found and not provided. Installing dsc package from store."); |
| 198 | + context.Reporter.Info() << Resource::String::ConfigurationInstallDscPackage; |
| 199 | + |
| 200 | + auto installDscContextPtr = context.CreateSubContext(); |
| 201 | + Execution::Context& installDscContext = *installDscContextPtr; |
| 202 | + auto previousThreadGlobals = installDscContext.SetForCurrentThread(); |
| 203 | + |
| 204 | + Manifest::ManifestInstaller dscInstaller; |
| 205 | +// TEMP: Until DSCv3 support is not experimental, allow the preview build to be installed automatically. |
| 206 | +// #ifndef AICLI_DISABLE_TEST_HOOKS |
| 207 | + dscInstaller.ProductId = "9PCX3HX4HZ0Z"; |
| 208 | +// #else |
| 209 | +// dscInstaller.ProductId = "9NVTPZWRC6KQ"; |
| 210 | +// #endif |
| 211 | + installDscContext.Add<Execution::Data::Installer>(std::move(dscInstaller)); |
| 212 | + installDscContext.Args.AddArg(Execution::Args::Type::InstallScope, Manifest::ScopeToString(Manifest::ScopeEnum::User)); |
| 213 | + installDscContext.Args.AddArg(Execution::Args::Type::Silent); |
| 214 | + installDscContext.Args.AddArg(Execution::Args::Type::Force); |
| 215 | + |
| 216 | + installDscContext << MSStoreInstall; |
| 217 | + |
| 218 | + if (installDscContext.IsTerminated()) |
| 219 | + { |
| 220 | + AICLI_LOG(Config, Error, << "Failed to install dsc v3 package and could not find dsc.exe, it must be provided by the user."); |
| 221 | + context.Reporter.Error() << Resource::String::ConfigurationInstallDscPackageFailed; |
| 222 | + THROW_WIN32(ERROR_FILE_NOT_FOUND); |
| 223 | + } |
| 224 | + } |
| 225 | + } |
190 | 226 |
|
191 | 227 | if (Logging::Log().IsEnabled(Logging::Channel::Config, Logging::Level::Verbose)) |
192 | 228 | { |
|
0 commit comments