예제 #1
0
        /// <summary>
        /// Checks if the project is a web application.
        /// </summary>
        /// <param name="projectParserResult">the parsed project</param>
        /// <returns>true if the project is a web application</returns>
        /// <example>
        /// Check if a parsed project is a web application
        /// <code>
        /// CustomParseProjectResult project = ParseProject(new FilePath("test.csproj"), "Release");
        /// if (project.IsWebApplication()) { ... }
        /// </code>
        /// </example>
        public static bool IsWebApplication(this CustomProjectParserResult projectParserResult)
        {
            if (projectParserResult.IsNetFramework)
            {
                if (!projectParserResult.ProjectTypeGuids.Any())
                {
                    return(false);
                }

                return(projectParserResult.IsType(ProjectType.AspNetMvc1) ||
                       projectParserResult.IsType(ProjectType.AspNetMvc2) ||
                       projectParserResult.IsType(ProjectType.AspNetMvc3) ||
                       projectParserResult.IsType(ProjectType.AspNetMvc4) ||
                       projectParserResult.IsType(ProjectType.AspNetMvc5) ||
                       projectParserResult.IsType(ProjectType.WebApplication) ||
                       projectParserResult.IsType(ProjectType.WebSite));
            }

            return(projectParserResult.IsNetCore && projectParserResult.NetCore.IsWeb);
        }
        /// <summary>
        /// Gets the output assembly path for a SolutionProject
        /// </summary>
        /// <param name="solutionProject">The solutionproject</param>
        /// <param name="project">The parsed project</param>
        /// <returns>The SolutionProject output assembly path</returns>
        /// <example>
        /// Gets an absolute assembly path for a project
        /// <code>
        /// var projects = ParseSolution(new FilePath("test.sln")).GetProjects();
        /// project[0].GetAssemblyFilePath();
        /// </code>
        /// </example>
        public static FilePath GetAssemblyFilePath(this SolutionProject solutionProject, CustomProjectParserResult project)
        {
            solutionProject.ThrowIfNull(nameof(solutionProject));
            project.ThrowIfNull(nameof(project));

            var assemblyFilePath = project.GetAssemblyFilePath();

            return(solutionProject.Path.GetDirectory().CombineWithFilePath(assemblyFilePath));
        }
예제 #3
0
 /// <summary>
 /// Checks the parsed projects type
 /// </summary>
 /// <param name="projectParserResult">the parsed project</param>
 /// <param name="projectType">the <see cref="ProjectType"/> to check</param>
 /// <returns>true if the project type matches</returns>
 /// <remarks>Project Types are not supported in NetCore, this extension is for the Net Framework only</remarks>
 /// <example>
 /// Checks the project type
 /// <code>
 /// CustomParseProjectResult project = ParseProject(new FilePath("test.csproj"), "Release");
 /// project.IsType(ProjectType.CSharp); // true
 /// </code>
 /// </example>
 public static bool IsType(this CustomProjectParserResult projectParserResult, ProjectType projectType)
 {
     return(projectType.HasFlag(ProjectType.Unspecified) ? projectParserResult.ProjectTypeGuids.IsNullOrEmpty() : projectParserResult.ProjectTypeGuids.Any(x => x.EqualsIgnoreCase(SolutionParserExtensions.Types[projectType])));
 }
예제 #4
0
 /// <summary>
 /// Gets a parsed projects output assembly path
 /// </summary>
 /// <param name="projectParserResult">the parsed project</param>
 /// <returns>the output assembly path</returns>
 /// <example>
 /// Returns the absolute project assembly file path, respects build config and platform settings
 /// <code>
 /// CustomParseProjectResult project = ParseProject(new FilePath("test.csproj"), "Release");
 /// project.GetAssemblyFilePath(); // returns '/root/project/bin/release/test.dll'
 /// </code>
 /// </example>
 public static FilePath GetAssemblyFilePath(this CustomProjectParserResult projectParserResult)
 {
     return
         (projectParserResult.OutputPath.CombineWithFilePath(projectParserResult.AssemblyName +
                                                             projectParserResult.GetExtension()));
 }
예제 #5
0
 /// <summary>
 /// Returns the parsed projects output assembly extension
 /// </summary>
 /// <param name="projectParserResult">the parsed project</param>
 /// <returns>the output assembly's file extension</returns>
 /// <example>
 /// Gets the output assembly extension
 /// <code>
 /// CustomParseProjectResult project = ParseProject(new FilePath("test.csproj"), "Release");
 /// project.GetExtension(); // ".dll" or ".exe"
 /// </code>
 /// </example>
 public static string GetExtension(this CustomProjectParserResult projectParserResult)
 {
     return(projectParserResult.IsLibrary()
         ? ".dll"
         : ".exe");
 }
예제 #6
0
 /// <summary>
 /// Checks if the project is a library
 /// </summary>
 /// <param name="projectParserResult">the parsed project</param>
 /// <returns>true if the project is a library</returns>
 /// <example>
 /// Check if a parsed project is a library or exe
 /// <code>
 /// CustomParseProjectResult project = ParseProject(new FilePath("test.csproj"), "Release");
 /// if (project.IsLibrary()) { ... }
 /// </code>
 /// </example>
 public static bool IsLibrary(this CustomProjectParserResult projectParserResult)
 {
     return(projectParserResult.OutputType.Equals("Library", StringComparison.InvariantCultureIgnoreCase));
 }