public async Task Parse()

in src/AWS.Deploy.Common/ProjectDefinitionParser.cs [43:104]


        public async Task<ProjectDefinition> Parse(string projectPath)
        {
            if (_directoryManager.Exists(projectPath))
            {
                projectPath = _directoryManager.GetDirectoryInfo(projectPath).FullName;
                var files = _directoryManager.GetFiles(projectPath, "*.csproj");
                if (files.Length == 1)
                {
                    projectPath = Path.Combine(projectPath, files[0]);
                }
                else if (files.Length == 0)
                {
                    files = _directoryManager.GetFiles(projectPath, "*.fsproj");
                    if (files.Length == 1)
                    {
                        projectPath = Path.Combine(projectPath, files[0]);
                    }
                }
            }

            if (!_fileManager.Exists(projectPath))
            {
                throw new ProjectFileNotFoundException(DeployToolErrorCode.ProjectPathNotFound, $"Failed to find a valid .csproj or .fsproj file at path {projectPath}");
            }

            var extension = Path.GetExtension(projectPath);
            if (!string.Equals(extension, ".csproj") && !string.Equals(extension, ".fsproj"))
            {
                var errorMeesage = $"Invalid project path {projectPath}. The project path must point to a .csproj or .fsproj file";
                throw new ProjectFileNotFoundException(DeployToolErrorCode.ProjectPathNotFound, errorMeesage);
            }

            var xmlProjectFile = new XmlDocument();
            xmlProjectFile.LoadXml(await _fileManager.ReadAllTextAsync(projectPath));

            var projectDefinition =  new ProjectDefinition(
                xmlProjectFile,
                projectPath,
                await GetProjectSolutionFile(projectPath),
                xmlProjectFile.DocumentElement?.Attributes["Sdk"]?.Value ??
                    throw new InvalidProjectDefinitionException(DeployToolErrorCode.ProjectParserNoSdkAttribute,
                        "The project file that is being referenced does not contain and 'Sdk' attribute.")
                );

            var targetFramework = xmlProjectFile.GetElementsByTagName("TargetFramework");
            if (targetFramework.Count > 0)
            {
                projectDefinition.TargetFramework = targetFramework[0]?.InnerText;
            }

            var assemblyName = xmlProjectFile.GetElementsByTagName("AssemblyName");
            if (assemblyName.Count > 0)
            {
                projectDefinition.AssemblyName = (string.IsNullOrWhiteSpace(assemblyName[0]?.InnerText) ? Path.GetFileNameWithoutExtension(projectPath) : assemblyName[0]?.InnerText);
            }
            else
            {
                projectDefinition.AssemblyName = Path.GetFileNameWithoutExtension(projectPath);
            }

            return projectDefinition;
        }