/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Tools/Shared/SecretsHelpers/MsBuildProjectFinder.cs
54 строки
2 KB
Jan Jones
Support file-based apps in user-secrets (#63496)
16 сен 2025, 20:34
Не верифицирован
16 сен 2025, 20:34
f7d34bf
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Linq; using Microsoft.AspNetCore.Tools; using Microsoft.Extensions.Tools.Internal; internal sealed class MsBuildProjectFinder { private readonly string _directory; public MsBuildProjectFinder(string directory) { ArgumentException.ThrowIfNullOrEmpty(directory); _directory = directory; } public string FindMsBuildProject(string project) { var projectPath = project ?? _directory; if (!Path.IsPathRooted(projectPath)) { projectPath = Path.Combine(_directory, projectPath); } if (Directory.Exists(projectPath)) { var projects = Directory.EnumerateFileSystemEntries(projectPath, "*.*proj", SearchOption.TopDirectoryOnly) .Where(f => !".xproj".Equals(Path.GetExtension(f), StringComparison.OrdinalIgnoreCase)) .ToList(); if (projects.Count > 1) { throw new FileNotFoundException(SecretsHelpersResources.FormatError_MultipleProjectsFound(projectPath)); } if (projects.Count == 0) { throw new FileNotFoundException(SecretsHelpersResources.FormatError_NoProjectsFound(projectPath)); } return projects[0]; } if (!File.Exists(projectPath)) { throw new FileNotFoundException(SecretsHelpersResources.FormatError_File_NotFound(projectPath)); } return projectPath; } }