Exemple #1
0
        public async Task GeneratorShouldBeInvokedProperly()
        {
            var conan   = new ConanRunner(ResourceUtils.ConanShim);
            var project = new ConanProject
            {
                Path           = ".",
                InstallPath    = "./conan",
                Configurations =
                {
                    new ConanConfiguration
                    {
                        Architecture    = "x86_64",
                        BuildType       = "Debug",
                        CompilerToolset = "v141",
                        CompilerVersion = "15"
                    }
                }
            };

            using (var process = await conan.Install(project, project.Configurations.Single()))
            {
                Assert.Equal("install . -g visual_studio_multi " +
                             "--install-folder ./conan " +
                             "-s arch=x86_64 " +
                             "-s build_type=Debug " +
                             "-s compiler.toolset=v141 " +
                             "-s compiler.version=15 " +
                             "--build missing --update", process.StartInfo.Arguments);
            }
        }
Exemple #2
0
        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 async Task InstallDependencies(ConanRunner conan, ConanProject project)
        {
            var installPath = project.InstallPath;
            await Task.Run(() => Directory.CreateDirectory(installPath));

            var logFilePath = Path.Combine(installPath, "conan.log");

            using (var logFile = File.Open(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                using (var logStream = new StreamWriter(logFile))
                {
                    foreach (var configuration in project.Configurations)
                    {
                        var process = await conan.Install(project, configuration);

                        await logStream.WriteLineAsync(
                            $"[Conan.VisualStudio] Calling process '{process.StartInfo.FileName}' " +
                            $"with arguments '{process.StartInfo.Arguments}'");

                        using (var reader = process.StandardOutput)
                        {
                            string line;
                            while ((line = await reader.ReadLineAsync()) != null)
                            {
                                await logStream.WriteLineAsync(line);
                            }
                        }

                        var exitCode = await process.WaitForExitAsync();

                        if (exitCode != 0)
                        {
                            _dialogService.ShowPluginError(
                                $"Conan has returned exit code '{exitCode}' " +
                                $"while processing configuration '{configuration}'. " +
                                $"Please check file '{logFilePath}' for details.");
                            return;
                        }
                    }

                    _dialogService.ShowInfo("Conan dependencies have been installed successfully.");
                }
        }
Exemple #4
0
        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);
        }