/// <summary> /// Determine if a file is v2 or v3 /// </summary> private void GetInputsFromFile(string projectFilePath, PackageRestoreInputs packageRestoreInputs) { // An argument was passed in. It might be a solution file or directory, // project file, project.json, or packages.config file var projectFileName = Path.GetFileName(projectFilePath); if (ProjectJsonPathUtilities.IsProjectConfig(projectFileName)) { // project.json or projName.project.json packageRestoreInputs.RestoreV3Context.Inputs.Add(projectFilePath); } else if (IsPackagesConfig(projectFileName)) { // restoring from packages.config or packages.projectname.config file packageRestoreInputs.PackagesConfigFiles.Add(projectFilePath); } else if (projectFileName.EndsWith("proj", StringComparison.OrdinalIgnoreCase)) { // For msbuild files find the project.json or packages.config file, // if neither exist skip it var projectName = Path.GetFileNameWithoutExtension(projectFileName); var dir = Path.GetDirectoryName(projectFilePath); var projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(dir, projectName); var packagesConfigPath = GetPackageReferenceFile(projectFilePath); // Check for project.json if (File.Exists(projectJsonPath)) { if (MsBuildUtility.IsMsBuildBasedProject(projectFilePath)) { // Add the project file path if it allows p2ps packageRestoreInputs.RestoreV3Context.Inputs.Add(projectFilePath); } else { // Unknown project type, add the project.json by itself packageRestoreInputs.RestoreV3Context.Inputs.Add(projectJsonPath); } } else if (File.Exists(packagesConfigPath)) { // Check for packages.config, if it exists add it directly packageRestoreInputs.PackagesConfigFiles.Add(packagesConfigPath); } } else if (projectFileName.EndsWith(".dg", StringComparison.OrdinalIgnoreCase)) { packageRestoreInputs.RestoreV3Context.Inputs.Add(projectFilePath); } else if (projectFileName.EndsWith(".sln", StringComparison.OrdinalIgnoreCase)) { ProcessSolutionFile(projectFilePath, packageRestoreInputs); } else { // Not a file we know about. Try to be helpful without response. throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, RestoreRunner.GetInvalidInputErrorMessage(projectFileName), projectFileName)); } }
/// <summary> /// Determine if a file is v2 or v3 /// </summary> private void GetInputsFromFile(string projectFilePath, PackageRestoreInputs packageRestoreInputs) { // An argument was passed in. It might be a solution file or directory, // project file, or packages.config file var projectFileName = Path.GetFileName(projectFilePath); if (IsPackagesConfig(projectFileName)) { // restoring from packages.config or packages.projectname.config file packageRestoreInputs.PackagesConfigFiles.Add(projectFilePath); } else if (projectFileName.EndsWith("proj", StringComparison.OrdinalIgnoreCase)) { packageRestoreInputs.ProjectFiles.Add(projectFilePath); } else if (projectFileName.EndsWith(".dg", StringComparison.OrdinalIgnoreCase)) { packageRestoreInputs.RestoreV3Context.Inputs.Add(projectFilePath); } else if (projectFileName.EndsWith(".sln", StringComparison.OrdinalIgnoreCase)) { ProcessSolutionFile(projectFilePath, packageRestoreInputs); } else if (ProjectJsonPathUtilities.IsProjectConfig(projectFileName)) { // project.json is no longer allowed throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, LocalizedResourceManager.GetString("Error_ProjectJsonNotAllowed"), projectFileName)); } else { // Not a file we know about. Try to be helpful without response. throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, RestoreRunner.GetInvalidInputErrorMessage(projectFileName), projectFileName)); } }
private void ProcessSolutionFile(string solutionFileFullPath, PackageRestoreInputs restoreInputs) { restoreInputs.DirectoryOfSolutionFile = Path.GetDirectoryName(solutionFileFullPath); // restore packages for the solution var solutionLevelPackagesConfig = Path.Combine( restoreInputs.DirectoryOfSolutionFile, NuGetConstants.NuGetSolutionSettingsFolder, Constants.PackageReferenceFile); if (File.Exists(solutionLevelPackagesConfig)) { restoreInputs.PackagesConfigFiles.Add(solutionLevelPackagesConfig); } var projectFiles = MsBuildUtility.GetAllProjectFileNames(solutionFileFullPath, _msbuildDirectory.Value); foreach (var projectFile in projectFiles) { if (!File.Exists(projectFile)) { var message = string.Format(CultureInfo.CurrentCulture, LocalizedResourceManager.GetString("RestoreCommandProjectNotFound"), projectFile); Console.LogWarning(message); continue; } var normalizedProjectFile = Path.GetFullPath(projectFile); // packages.config var packagesConfigFilePath = GetPackageReferenceFile(normalizedProjectFile); // project.json var dir = Path.GetDirectoryName(normalizedProjectFile); var projectName = Path.GetFileNameWithoutExtension(normalizedProjectFile); var projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(dir, projectName); // project.json overrides packages.config if (File.Exists(projectJsonPath)) { // project.json inputs are resolved again against the p2p file // and are matched with the solution there // For known msbuild project types use the project if (MsBuildUtility.IsMsBuildBasedProject(normalizedProjectFile)) { restoreInputs.RestoreV3Context.Inputs.Add(normalizedProjectFile); } else { // For unknown types restore the project.json file without p2ps restoreInputs.RestoreV3Context.Inputs.Add(projectJsonPath); } } else if (File.Exists(packagesConfigFilePath)) { restoreInputs.PackagesConfigFiles.Add(packagesConfigFilePath); } } }
public static async Task MigrateAsync( BuildIntegratedNuGetProject project) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var dteProjectFullName = project.MSBuildProjectPath; var projectJsonFilePath = ProjectJsonPathUtilities.GetProjectConfigPath(Path.GetDirectoryName(project.MSBuildProjectPath), Path.GetFileNameWithoutExtension(project.MSBuildProjectPath)); if (!File.Exists(projectJsonFilePath)) { throw new FileNotFoundException(string.Format(Strings.Error_FileNotExists, projectJsonFilePath)); } var packageSpec = JsonPackageSpecReader.GetPackageSpec( Path.GetFileNameWithoutExtension(project.MSBuildProjectPath), projectJsonFilePath); if (packageSpec == null) { throw new InvalidOperationException( string.Format(Strings.Error_InvalidJson, projectJsonFilePath)); } await MigrateDependenciesAsync(project, packageSpec); var buildProject = EnvDTEProjectUtility.AsMSBuildEvaluationProject(dteProjectFullName); MigrateRuntimes(packageSpec, buildProject); RemoveProjectJsonReference(buildProject, projectJsonFilePath); await CreateBackupAsync(project, projectJsonFilePath); }
/// <summary> /// Load a project.json for an msbuild project file. /// This allows projectName.project.json for csproj but not for xproj. /// </summary> private PackageSpec GetPackageSpec(string msbuildProjectPath) { PackageSpec result = null; string path = null; var directory = Path.GetDirectoryName(msbuildProjectPath); var projectName = Path.GetFileNameWithoutExtension(msbuildProjectPath); if (msbuildProjectPath.EndsWith(XProjUtility.XProjExtension, StringComparison.OrdinalIgnoreCase)) { // Only project.json is allowed path = Path.Combine( directory, PackageSpec.PackageSpecFileName); } else { // Allow project.json or projectName.project.json path = ProjectJsonPathUtilities.GetProjectConfigPath(directory, projectName); } // Read the file if it exists and is not cached already if (!_projectJsonCache.TryGetValue(path, out result)) { if (File.Exists(path)) { result = JsonPackageSpecReader.GetPackageSpec(projectName, path); } _projectJsonCache.Add(path, result); } return(result); }
private IVsPathContext GetPathContextForProjectJson( IVsProjectAdapter vsProjectAdapter) { // generate project.lock.json file path from project file var projectFilePath = vsProjectAdapter.FullProjectPath; if (!string.IsNullOrEmpty(projectFilePath)) { var msbuildProjectFile = new FileInfo(projectFilePath); var projectNameFromMSBuildPath = Path.GetFileNameWithoutExtension(msbuildProjectFile.Name); string projectJsonPath = null; if (string.IsNullOrEmpty(projectNameFromMSBuildPath)) { projectJsonPath = Path.Combine(msbuildProjectFile.DirectoryName, ProjectJsonPathUtilities.ProjectConfigFileName); } else { projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath( msbuildProjectFile.DirectoryName, projectNameFromMSBuildPath); } if (File.Exists(projectJsonPath)) { var lockFilePath = ProjectJsonPathUtilities.GetLockFilePath(projectJsonPath); return(GetPathContextFromProjectLockFile(lockFilePath)); } } return(null); }
public static IReadOnlyList <PackageIdentity> GetOrderedProjectDependencies( BuildIntegratedNuGetProject buildIntegratedProject) { var results = new List <PackageIdentity>(); var lockFilePath = ProjectJsonPathUtilities.GetLockFilePath(buildIntegratedProject.JsonConfigPath); var lockFileFormat = new LockFileFormat(); // Read the lock file to find the full closure of dependencies if (File.Exists(lockFilePath)) { var lockFile = lockFileFormat.Read(lockFilePath); var dependencies = new HashSet <PackageDependencyInfo>(PackageIdentity.Comparer); foreach (var target in lockFile.Targets) { foreach (var targetLibrary in target.Libraries) { var identity = new PackageIdentity(targetLibrary.Name, targetLibrary.Version); var dependency = new PackageDependencyInfo(identity, targetLibrary.Dependencies); dependencies.Add(dependency); } } // Sort dependencies var sortedDependencies = SortPackagesByDependencyOrder(dependencies); results.AddRange(sortedDependencies); } return(results); }
private void BuildSymbolsPackage(string path) { PackageBuilder symbolsBuilder; if (ProjectJsonPathUtilities.IsProjectConfig(path)) { symbolsBuilder = CreatePackageBuilderFromProjectJson(path, _packArgs.GetPropertyValue); // Add output files AddOutputFiles(symbolsBuilder, includeSymbols: true); } else { symbolsBuilder = CreatePackageBuilderFromNuspec(path); } // remove unnecessary files when building the symbols package ExcludeFilesForSymbolPackage(symbolsBuilder.Files); if (!symbolsBuilder.Files.Any()) { throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, Strings.Error_PackageCommandNoFilesForSymbolsPackage, path, Strings.NuGetDocs)); } string outputPath = GetOutputPath(symbolsBuilder, _packArgs, symbols: true); InitCommonPackageBuilderProperties(symbolsBuilder); BuildPackage(symbolsBuilder, outputPath); }
public NuGetProject CreateNuGetProject(DotNetProject project, INuGetProjectContext context) { Runtime.AssertMainThread(); var projectSystem = new MonoDevelopMSBuildNuGetProjectSystem(project, context); string projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(project.BaseDirectory, project.Name); if (File.Exists(projectJsonPath)) { return(new BuildIntegratedProjectSystem( projectJsonPath, project.FileName, project, projectSystem, project.Name, settings)); } string baseDirectory = GetBaseDirectory(project); string folderNuGetProjectFullPath = PackagesFolderPathUtility.GetPackagesFolderPath(baseDirectory, settings); string packagesConfigFolderPath = project.BaseDirectory; return(new MSBuildNuGetProject( projectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath)); }
public void ApplyStandardProperties(RestoreRequest request) { request.PackageSaveMode = PackageSaveMode; if (request.ProjectStyle == ProjectStyle.PackageReference || request.ProjectStyle == ProjectStyle.DotnetToolReference || request.ProjectStyle == ProjectStyle.Standalone) { request.LockFilePath = Path.Combine(request.RestoreOutputPath, LockFileFormat.AssetsFileName); } else if (request.ProjectStyle != ProjectStyle.DotnetCliTool) { request.LockFilePath = ProjectJsonPathUtilities.GetLockFilePath(request.Project.FilePath); } if (request.Project.RestoreMetadata?.CacheFilePath == null) { request.Project.RestoreMetadata.CacheFilePath = NoOpRestoreUtilities.GetCacheFilePath(request); } request.MaxDegreeOfConcurrency = DisableParallel ? 1 : RestoreRequest.DefaultDegreeOfConcurrency; request.RequestedRuntimes.UnionWith(Runtimes); request.FallbackRuntimes.UnionWith(FallbackRuntimes); if (IsLowercaseGlobalPackagesFolder.HasValue) { request.IsLowercasePackagesDirectory = IsLowercaseGlobalPackagesFolder.Value; } if (LockFileVersion.HasValue && LockFileVersion.Value > 0) { request.LockFileVersion = LockFileVersion.Value; } // Run runtime asset checks for project.json, and for other types if enabled. if (ValidateRuntimeAssets == null) { if (request.ProjectStyle == ProjectStyle.ProjectJson || request.Project.RestoreMetadata == null) { request.ValidateRuntimeAssets = request.ProjectStyle == ProjectStyle.ProjectJson; } else { request.ValidateRuntimeAssets = request.Project.RestoreMetadata.ValidateRuntimeAssets; } } else { request.ValidateRuntimeAssets = ValidateRuntimeAssets.Value; } request.AllowNoOp = !request.CacheContext.NoCache && AllowNoOp; request.HideWarningsAndErrors = HideWarningsAndErrors; request.ParentId = ParentId; request.IsRestoreOriginalAction = IsRestoreOriginalAction; request.ReevaluateRestoreGraph = ReevaluateRestoreGraph; }
public void ProjectJsonPathUtilities_GetProjectConfigWithProjectName(string projectName, string fileName) { // Arrange & Act var generatedName = ProjectJsonPathUtilities.GetProjectConfigWithProjectName(projectName); // Assert Assert.Equal(fileName, generatedName); }
static IEnumerable <string> GetPossiblePackagesConfigOrProjectJsonFilePaths(string projectDirectory, string projectName) { yield return(GetNonDefaultProjectPackagesConfigFilePath(projectDirectory, projectName)); yield return(GetDefaultPackagesConfigFilePath(projectDirectory)); yield return(ProjectJsonPathUtilities.GetProjectConfigPath(projectDirectory, projectName)); }
public void ProjectJsonPathUtilities_GetLockFilePath(string configPath, string lockFilePath) { // Arrange & Act var result = ProjectJsonPathUtilities.GetLockFilePath(ConvertToUnix(configPath)); // Assert Assert.Equal(ConvertToUnix(lockFilePath), result); }
public void ProjectJsonPathUtilities_IsProjectConfig_False(string path) { // Arrange & Act var result = ProjectJsonPathUtilities.IsProjectConfig(ConvertToUnix(path)); // Assert Assert.False(result); }
private static List <string> GetProjectJsonFilesInDirectory(string path) { return(Directory.GetFiles(path, $"*{ProjectJsonPathUtilities.ProjectConfigFileName}", SearchOption.AllDirectories) .Where(file => ProjectJsonPathUtilities.IsProjectConfig(file)) .ToList()); }
//auto-restore project.json files when they're saved void FileChanged(object sender, FileEventArgs e) { if (PackageManagementServices.BackgroundPackageActionRunner.IsRunning) { return; } List <DotNetProject> projects = null; //collect all the projects with modified project.json files foreach (var eventInfo in e) { if (ProjectJsonPathUtilities.IsProjectConfig(eventInfo.FileName)) { var directory = eventInfo.FileName.ParentDirectory; foreach (var project in IdeApp.Workspace.GetAllItems <DotNetProject> ().Where(p => p.BaseDirectory == directory)) { if (projects == null) { projects = new List <DotNetProject> (); } projects.Add(project); } } } if (projects == null) { return; } //check that the projects have the correct backing system for project.json RefreshProjectsIfNecessary(projects); //queue up in a timeout in case this was kicked off from a command GLib.Timeout.Add(0, () => { if (projects.Count == 1) { var project = projects [0]; //check the project is still open if (IdeApp.Workspace.GetAllItems <DotNetProject> ().Any(p => p == project)) { RestorePackagesInProjectHandler.Run(projects [0]); } } else { var solution = projects [0].ParentSolution; //check the solution is still open if (IdeApp.Workspace.GetAllItems <Solution> ().Any(s => s == solution)) { RestorePackagesHandler.Run(solution); } } //TODO: handle project.json changing in multiple solutions at once return(false); }); }
public static bool IsProjectJsonFileName(this FilePath filePath) { if (filePath == null) { return(false); } return(ProjectJsonPathUtilities.IsProjectConfig(filePath)); }
public void ProjectJsonPathUtilities_GetProjectNameFromConfigFileName( string projectName, string fileName) { // Arrange & Act var result = ProjectJsonPathUtilities.GetProjectNameFromConfigFileName(fileName); // Assert Assert.Equal(projectName, result); }
private bool HasProjectJsonFile(string projectFilePath) { // Get possible project.json path var projectFileName = Path.GetFileName(projectFilePath); var projectName = Path.GetFileNameWithoutExtension(projectFileName); var dir = Path.GetDirectoryName(projectFilePath); var projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(dir, projectName); return(File.Exists(projectJsonPath)); }
/// <summary> /// Restore without writing the lock file /// </summary> internal static async Task <RestoreResult> RestoreAsync( BuildIntegratedNuGetProject project, PackageSpec packageSpec, ExternalProjectReferenceContext context, RestoreCommandProviders providers, CancellationToken token) { // Restoring packages var logger = context.Logger; logger.LogMinimal(string.Format(CultureInfo.CurrentCulture, Strings.BuildIntegratedPackageRestoreStarted, project.ProjectName)); using (var request = new RestoreRequest(packageSpec, providers, logger, disposeProviders: false)) { request.MaxDegreeOfConcurrency = PackageManagementConstants.DefaultMaxDegreeOfParallelism; request.LockFileVersion = await GetLockFileVersion(project, context); // Add the existing lock file if it exists var lockFilePath = ProjectJsonPathUtilities.GetLockFilePath(project.JsonConfigPath); request.LockFilePath = lockFilePath; request.ExistingLockFile = LockFileUtilities.GetLockFile(lockFilePath, logger); // Find the full closure of project.json files and referenced projects var projectReferences = await project.GetProjectReferenceClosureAsync(context); request.ExternalProjects = projectReferences.ToList(); token.ThrowIfCancellationRequested(); var command = new RestoreCommand(request); // Execute the restore var result = await command.ExecuteAsync(token); // Report a final message with the Success result if (result.Success) { logger.LogMinimal(string.Format(CultureInfo.CurrentCulture, Strings.BuildIntegratedPackageRestoreSucceeded, project.ProjectName)); } else { logger.LogMinimal(string.Format(CultureInfo.CurrentCulture, Strings.BuildIntegratedPackageRestoreFailed, project.ProjectName)); } return(result); } }
/// <summary> /// True if the project has a project.json file, indicating that it is build integrated /// </summary> public static async Task <bool> HasBuildIntegratedConfig(EnvDTE.Project project) { var projectNameConfig = ProjectJsonPathUtilities.GetProjectConfigWithProjectName(project.Name); var containsProjectJson = await ContainsFile(project, projectNameConfig); var containsProjectNameJson = await ContainsFile( project, ProjectJsonPathUtilities.ProjectConfigFileName); return(containsProjectJson || containsProjectNameJson); }
public Task <bool> Supports(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } // True if dir or project.json file var result = Directory.Exists(path) || (File.Exists(path) && ProjectJsonPathUtilities.IsProjectConfig(path)); return(Task.FromResult(result)); }
public override bool Execute() { var packagesChecked = new HashSet <PackageIdentity>(); var packageResolver = new VersionFolderPathResolver(PackagesFolder); var needsRestore = new LinkedList <ITaskItem>(); var lockFileFormat = new LockFileFormat(); ProjectJsons.AsParallel().ForAll(project => { string projectJsonPath = project.GetMetadata("FullPath"); string projectLockJsonPath = ProjectJsonPathUtilities.GetLockFilePath(projectJsonPath); if (!File.Exists(projectLockJsonPath)) { Log.LogMessage(MessageImportance.Low, $"{projectJsonPath} requires restore because {projectLockJsonPath} is missing."); AddLock(needsRestore, project); return; } if (File.GetLastWriteTime(projectJsonPath) > File.GetLastWriteTime(projectLockJsonPath)) { Log.LogMessage(MessageImportance.Low, $"{projectJsonPath} requires restore because {projectLockJsonPath} is older."); AddLock(needsRestore, project); return; } var packages = ReadPackages(projectLockJsonPath); foreach (var package in packages) { // Each id/version only needs to be checked once if (AddLock(packagesChecked, package)) { // Verify the SHA exists for each package, don't validate the content since we assume our packages are immutable var hashPath = packageResolver.GetHashPath(package.Id, package.Version); if (!File.Exists(hashPath)) { Log.LogMessage(MessageImportance.Low, $"{projectJsonPath} requires restore because {package} is missing."); AddLock(needsRestore, project); break; } } } }); ProjectJsonsRequiringRestore = needsRestore.ToArray(); RestoreRequired = ProjectJsonsRequiringRestore.Length > 0; return(!Log.HasLoggedErrors); }
/// <summary> /// True if the project has a project.json file, indicating that it is build integrated /// </summary> public static async Task <bool> HasBuildIntegratedConfig(EnvDTE.Project project) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var projectNameConfig = ProjectJsonPathUtilities.GetProjectConfigWithProjectName(project.Name); var containsProjectJson = await ContainsFileAsync(project, projectNameConfig); var containsProjectNameJson = await ContainsFileAsync( project, ProjectJsonPathUtilities.ProjectConfigFileName); return(containsProjectJson || containsProjectNameJson); }
public NuGetProject CreateNuGetProject(DotNetProject project, INuGetProjectContext context) { Runtime.AssertMainThread(); var nugetAwareProject = project as INuGetAwareProject; if (nugetAwareProject != null) { return(nugetAwareProject.CreateNuGetProject()); } NuGetProject dotNetCoreProject = DotNetCoreNuGetProject.Create(project); if (dotNetCoreProject != null) { return(dotNetCoreProject); } NuGetProject packageReferenceProject = PackageReferenceNuGetProject.Create(project); if (packageReferenceProject != null) { return(packageReferenceProject); } var projectSystem = new MonoDevelopMSBuildNuGetProjectSystem(project, context); string projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath(project.BaseDirectory, project.Name); if (File.Exists(projectJsonPath)) { return(new ProjectJsonBuildIntegratedNuGetProject( projectJsonPath, project.FileName, project, settings)); } string baseDirectory = GetBaseDirectory(project); string folderNuGetProjectFullPath = PackagesFolderPathUtility.GetPackagesFolderPath(baseDirectory, settings); string packagesConfigFolderPath = project.BaseDirectory; return(new MonoDevelopMSBuildNuGetProject( projectSystem, folderNuGetProjectFullPath, packagesConfigFolderPath)); }
public void ProjectJsonPathUtilities_GetLockFilePathWithNoFiles() { // Arrange using (var randomProjectFolderPath = TestFileSystemUtility.CreateRandomTestFolder()) { var expected = Path.Combine(randomProjectFolderPath, "project.json"); // Act var path = ProjectJsonPathUtilities.GetProjectConfigPath(randomProjectFolderPath, "abc"); // Assert Assert.Equal(expected, path); // Clean-up } }
private static void CreatePart(ZipArchive package, string path, Stream sourceStream) { if (PackageHelper.IsManifest(path) || ProjectJsonPathUtilities.IsProjectConfig(path)) { return; } string entryName = CreatePartEntryName(path); var entry = package.CreateEntry(entryName, CompressionLevel.Optimal); using (var stream = entry.Open()) { sourceStream.CopyTo(stream); } }
public void ProjectJsonPathUtilities_GetLockFilePathWithProjectNameOnly() { // Arrange using (var randomProjectFolderPath = TestFileSystemUtility.CreateRandomTestFolder()) { var projNameFile = Path.Combine(randomProjectFolderPath, "abc.project.json"); CreateFile(projNameFile); // Act var path = ProjectJsonPathUtilities.GetProjectConfigPath(randomProjectFolderPath, "abc"); var fileName = Path.GetFileName(path); // Assert Assert.Equal(fileName, "abc.project.json"); } }
private PackageArchiveReader BuildPackage(string path) { string extension = Path.GetExtension(path); if (ProjectJsonPathUtilities.IsProjectConfig(path)) { return(BuildFromProjectJson(path)); } else if (extension.Equals(NuGetConstants.ManifestExtension, StringComparison.OrdinalIgnoreCase)) { return(BuildFromNuspec(path)); } else { return(BuildFromProjectFile(path)); } }
public void ProjectJsonPathUtilities_GetLockFilePathWithProjectJsonOnly() { // Arrange using (var randomProjectFolderPath = TestDirectory.Create()) { var projJsonFile = Path.Combine(randomProjectFolderPath, "project.json"); CreateFile(projJsonFile); // Act var path = ProjectJsonPathUtilities.GetProjectConfigPath(randomProjectFolderPath, "abc"); var fileName = Path.GetFileName(path); // Assert Assert.Equal(fileName, "project.json"); // Clean-up } }