private async Task InstallDependenciesAsync(ConanRunner conan, ConanProject project) { foreach (var configuration in project.Configurations) { var installPath = configuration.InstallPath; await Task.Run(() => Directory.CreateDirectory(installPath)); var logFilePath = Path.Combine(installPath, $"conan_{Guid.NewGuid().ToString()}.log"); using (var logFile = File.Open(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var logStream = new StreamWriter(logFile)) { ConanGeneratorType generator = _settingsService.GetConanGenerator(); ConanBuildType build = _settingsService.GetConanBuild(); bool update = _settingsService.GetConanUpdate(); var process = await conan.Install(project, configuration, generator, build, update, _errorListService); string message = $"[Conan.VisualStudio] Calling process '{process.StartInfo.FileName}' " + $"with arguments '{process.StartInfo.Arguments}'"; Logger.Log(message); await logStream.WriteLineAsync(message); using (var reader = process.StandardOutput) { string line; while ((line = await reader.ReadLineAsync()) != null) { await logStream.WriteLineAsync(line); Logger.Log(line); } } var exitCode = await process.WaitForExitAsync(); if (exitCode != 0) { message = $"Conan has returned exit code '{exitCode}' " + $"while processing configuration '{configuration}'. " + $"Please check file '{logFilePath}' for details."; Logger.Log(message); await logStream.WriteLineAsync(message); _errorListService.WriteError(message, logFilePath); return; } else { message = $"[Conan.VisualStudio] Conan has succsessfully installed configuration '{configuration}'"; Logger.Log(message); await logStream.WriteLineAsync(message); _errorListService.WriteMessage(message); } } } }
private string BuildOptions(ConanBuildType build, bool update) { string options = ""; if (build != ConanBuildType.none) { if (build == ConanBuildType.always) { options += " --build"; } else { options += " --build=" + build.ToString(); } } if (update) { options += " --update"; } return(options); }
public Task <Process> Install(ConanProject project, ConanConfiguration configuration, ConanGeneratorType generator, ConanBuildType build, bool update) { string ProcessArgument(string name, string value) => $"-s {name}={Escape(value)}"; var arguments = string.Empty; if (_conanSettings != null) { var installConfig = _conanSettings.ConanCommands.FirstOrDefault(c => c.Name.Equals("install")); arguments = installConfig.Args; } else { string generatorName = generator.ToString(); var settingValues = new[]
private async Task <bool> InstallDependenciesAsync(ConanRunner conan, ConanProject project) { foreach (var configuration in project.Configurations) { var installPath = configuration.InstallPath; await Task.Run(() => Directory.CreateDirectory(installPath)); var logFilePath = Path.Combine(installPath, $"conan_{Guid.NewGuid().ToString()}.log"); using (var logFile = File.Open(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var logStream = new StreamWriter(logFile)) { ConanGeneratorType generator = _settingsService.GetConanGenerator(); ConanBuildType build = _settingsService.GetConanBuild(); bool update = _settingsService.GetConanUpdate(); ProcessStartInfo process = null; try { // Run 'conan --version' for log purposes process = conan.Version(); int exitCode = await Utils.RunProcessAsync(process, logStream); if (exitCode != 0) { string message = "Cannot get Conan version, check that the " + "executable is pointing to a valid one"; Logger.Log(message); await logStream.WriteLineAsync(message); _errorListService.WriteError(message, logFilePath); } // Run the install process = conan.Install(project, configuration, generator, build, update, _errorListService); exitCode = await Utils.RunProcessAsync(process, logStream); if (exitCode != 0) { string message = $"Conan has returned exit code '{exitCode}' " + $"while processing configuration '{configuration}'. " + $"Please check file '{logFilePath}' for details."; Logger.Log(message); await logStream.WriteLineAsync(message); _errorListService.WriteError(message, logFilePath); return(false); } else { string message = $"[Conan.VisualStudio] Conan has succsessfully " + $"installed configuration '{configuration}'"; Logger.Log(message); await logStream.WriteLineAsync(message); _errorListService.WriteMessage(message); } } catch (System.ComponentModel.Win32Exception e) { string message = $"[Conan.VisualStudio] Unhandled error running '{process.FileName}'" + $": {e.Message}. Check log file '{logFilePath}' for details"; Logger.Log(message); await logStream.WriteLineAsync(message); _errorListService.WriteError(message); return(false); } } } return(true); }
public Task <Process> Install(ConanProject project, ConanConfiguration configuration, ConanGeneratorType generator, ConanBuildType build, bool update, Core.IErrorListService errorListService) { string ProcessArgument(string name, string value) => $"-s {name}={Escape(value)}"; var arguments = string.Empty; string profile = project.getProfile(configuration, errorListService); if (profile != null) { string generatorName = generator.ToString(); string options = ""; if (build != ConanBuildType.none) { options += " --build " + build.ToString(); } if (update) { options += " --update"; } arguments = $"install {Escape(project.Path)} " + $"-g {generatorName} " + $"--install-folder {Escape(configuration.InstallPath)} " + $"--profile {Escape(profile)}" + $"{options}"; } else if (_conanSettings != null) { var installConfig = _conanSettings.ConanCommands.FirstOrDefault(c => c.Name.Equals("install")); arguments = installConfig.Args; } else { string generatorName = generator.ToString(); var settingValues = new[]
public ProcessStartInfo Install(ConanProject project, ConanConfiguration configuration, ConanGeneratorType generator, ConanBuildType build, bool update, Core.IErrorListService errorListService) { string ProcessArgument(string name, string value) => $"-s {name}={Escape(value)}"; var arguments = string.Empty; string profile = project.getProfile(configuration, errorListService); if (profile != null) { string generatorName = generator.ToString(); arguments = $"install {Escape(project.Path)} " + $"-g {generatorName} " + $"--install-folder {Escape(configuration.InstallPath)} " + $"--profile {Escape(profile)}" + $"{BuildOptions(build, update)}"; } else { string generatorName = generator.ToString(); var settingValues = new[]