/// <summary>
        /// Creates a solution file at the specified file-path.
        /// </summary>
        /// <remarks>
        /// This method feeds the solution directory-path and solution-name value required to have the dotnet new command create a solution-file at the specified path.
        /// </remarks>
        public static void CreateSolutionFile(SolutionFilePath solutionFilePath, DotnetNewConventions conventions, ILogger logger)
        {
            var solutionDirectoryPath            = PathUtilities.GetDirectoryPath(solutionFilePath).AsSolutionDirectoryPath();
            var solutionFileName                 = PathUtilities.GetFileName(solutionFilePath).AsSolutionFileName();
            var solutionFileNameWithoutExtension = PathUtilities.GetFileNameWithoutExtension(solutionFileName);
            var solutionName = conventions.SolutionNameFromSolutionFileNameWithoutExtension(solutionFileNameWithoutExtension);

            var createdSolutionFilePath = DotnetCommandServicesProvider.CreateSolutionFile(solutionDirectoryPath, solutionName, logger);

            // Throw an exception if the solution file-path created by dotnet new is not the one we were expecting.
            if (createdSolutionFilePath.Value != solutionFilePath.Value)
            {
                throw new Exception($"Solution creation file path mismatch.\nExpected: {solutionFilePath}\nCreated: {createdSolutionFilePath}");
            }
        }
 /// <summary>
 /// Uses the <see cref="DotnetNewConventions.Instance"/>.
 /// </summary>
 public static void CreateSolutionFile(SolutionFilePath solutionFilePath, ILogger logger)
 {
     DotnetCommandServicesProvider.CreateSolutionFile(solutionFilePath, DotnetNewConventions.Instance, logger);
 }
Exemple #3
0
 public void CreateSolutionFile(SolutionFilePath solutionFilePath)
 {
     DotnetCommandServicesProvider.CreateSolutionFile(solutionFilePath, this.Logger);
 }