Example #1
0
        public static DotnetNewConventions GetDefault()
        {
            var conventions = new DotnetNewConventions(
                DotnetNewDefaultConventions.ProjectFileNameWithoutExtensionFromProjectName,
                DotnetNewDefaultConventions.ProjectNameFromProjectFileNameWithoutExtension,
                DotnetNewDefaultConventions.SolutionFileNameWithoutExtensionFromSolutionName,
                DotnetNewDefaultConventions.SolutionNameFromSolutionFileNameWithoutExtension
                );

            return(conventions);
        }
        /// <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}");
            }
        }
        public static void CreateProjectFile(DotnetNewProjectType projectType, ProjectFilePath projectFilePath, DotnetNewConventions conventions, ILogger logger)
        {
            var projectDirectoryPath            = PathUtilities.GetDirectoryPath(projectFilePath).AsProjectDirectoryPath();
            var projectFileName                 = PathUtilities.GetFileName(projectFilePath).AsProjectFileName();
            var projectFileNameWithoutExtension = PathUtilities.GetFileNameWithoutExtension(projectFileName);
            var projectName = conventions.ProjectNameFromProjectFileNameWithoutExtension(projectFileNameWithoutExtension);

            var createdProjectFilePath = DotnetCommandServicesProvider.CreateProjectFile(projectType, projectName, projectDirectoryPath, logger);

            // Throw an exception if the solution file-path created by dotnet new is not the one we were expecting.
            if (createdProjectFilePath.Value != projectFilePath.Value)
            {
                throw new Exception($"Project creation file path mismatch.\nExpected: {projectFilePath}\nCreated: {createdProjectFilePath}");
            }
        }
Example #4
0
        public static SolutionFilePath GetSolutionFilePath(SolutionDirectoryPath solutionDirectoryPath, SolutionName solutionName, DotnetNewConventions conventions)
        {
            var solutionFileName = Utilities.GetSolutionFileName(solutionName, conventions);

            var solutionFilePath = VsIoUtilities.GetSolutionFilePath(solutionDirectoryPath, solutionFileName);

            return(solutionFilePath);
        }
Example #5
0
        public static SolutionFileName GetSolutionFileName(SolutionName solutionName, DotnetNewConventions conventions)
        {
            var solutionFileNameWithoutExtension = conventions.SolutionFileNameWithoutExtensionFromSolutionName(solutionName);

            var solutionFileName = VsIoUtilities.GetSolutionFileName(solutionFileNameWithoutExtension);

            return(solutionFileName);
        }
Example #6
0
        public static ProjectFilePath GetCSharpProjectFilePath(ProjectDirectoryPath projectDirectoryPath, ProjectName projectName, DotnetNewConventions conventions)
        {
            var projectFileName = Utilities.GetCSharpProjectFileName(projectName, conventions);

            var projectFilePath = VsIoUtilities.GetProjectFilePath(projectDirectoryPath, projectFileName);

            return(projectFilePath);
        }
Example #7
0
        public static ProjectFileName GetCSharpProjectFileName(ProjectName projectName, DotnetNewConventions conventions)
        {
            var projectFileNameWithoutExtension = conventions.ProjectFileNameWithoutExtensionFromProjectName(projectName);

            var projectFileName = VsIoUtilities.GetCSharpProjectFileName(projectFileNameWithoutExtension);

            return(projectFileName);
        }