public string WriteToFileSystem(Solution solution, string outputPath)
        {
            if (solution is null)
            {
                throw new ArgumentNullException(nameof(solution));
            }

            var createSolutionCommand = DotNet.New(_outputWriter).Solution().InFolder(outputPath).WithName(solution.Name).Build();

            createSolutionCommand.Execute((innerException) => new ProjectCreationNotPossibleException("Could not create solution.", innerException));
            string solutionFilePath = Path.Combine(outputPath, $"{solution.Name}.sln");

            WriteProjects(solution, outputPath, solutionFilePath);

            if (solution.NugetConfig != null)
            {
                _projectFileWriter.Write(solution.NugetConfig, outputPath);
            }

            var targetFramework = solution.Projects
                                  .Select(p => p.TargetFrameworks)
                                  .FirstOrDefault();

            var sdk = _netCoreSdkInfoProvider.GetSdkFromTargetFramework(targetFramework);

            if (targetFramework != 0 && sdk != null)
            {
                var globalJsonBuilder = new GlobalJsonBuilder().WithSdk(sdk);

                var globalJsonFile = globalJsonBuilder.ToProjectFile();
                _projectFileWriter.Write(globalJsonFile, outputPath);
            }

            return(solutionFilePath);
        }
        public string WriteToFileSystem(Solution solution, string outputPath)
        {
            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            if (solution is null)
            {
                throw new ArgumentNullException(nameof(solution));
            }

            var targetFramework =
                solution.Projects
                .Select(p => p.TargetFrameworks)
                .FirstOrDefault();

            var sdk = !string.IsNullOrWhiteSpace(solution.SdkVersion)
                ? new NetCoreSdkInfo(solution.SdkVersion)
                : _netCoreSdkInfoProvider.GetSdkFromTargetFramework(targetFramework);

            if (targetFramework != 0 && sdk != null)
            {
                var globalJsonBuilder = new GlobalJsonBuilder().WithSdk(sdk);

                var globalJsonFile = globalJsonBuilder.ToProjectFile();
                _fileWriter.Write(globalJsonFile, outputPath);
            }

            AllowNet6ToTestOlderFrameworks(targetFramework);

            var createSolutionCommand = DotNet.New(_outputWriter).Solution().InFolder(outputPath).WithName(solution.Name).Build();

            createSolutionCommand.ExecuteWithRetry(1, TimeSpan.FromSeconds(1),
                                                   (innerException) => new ProjectCreationNotPossibleException("Could not create solution.", innerException));
            string solutionFilePath = Path.Combine(outputPath, $"{solution.Name}.sln");

            WriteProjects(solution, outputPath, solutionFilePath);

            if (solution.NugetConfig != null)
            {
                _fileWriter.Write(solution.NugetConfig, outputPath);
            }

            foreach (var file in solution.Files)
            {
                _fileWriter.Write(file, outputPath);
            }

            return(solutionFilePath);
        }