Temp
This commit is contained in:
parent
e5f6107d88
commit
12e8e8eca7
2 changed files with 52 additions and 1 deletions
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Build.Execution;
|
||||||
|
using NuGet.ProjectModel;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
{
|
||||||
|
internal class LockFilePathCalculator
|
||||||
|
{
|
||||||
|
public string GetLockFilePath(string projectDirectory)
|
||||||
|
{
|
||||||
|
return ResolveLockFilePathUsingCSProj(projectDirectory) ??
|
||||||
|
ReturnProjectLockJson(projectDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ResolveLockFilePathUsingCSProj(string projectDirectory)
|
||||||
|
{
|
||||||
|
string csProjPath = GetCSProjPath(projectDirectory);
|
||||||
|
if(csProjPath != null)
|
||||||
|
{
|
||||||
|
ProjectInstance projectInstance = new ProjectInstance(csProjPath, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ReturnProjectLockJson(string projectDirectory)
|
||||||
|
{
|
||||||
|
return Path.Combine(projectDirectory, LockFileFormat.LockFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCSProjPath(string projectDirectory)
|
||||||
|
{
|
||||||
|
string[] projectFiles = Directory.GetFiles(projectDirectory, "*.*proj");
|
||||||
|
|
||||||
|
if (projectFiles.Length == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else if (projectFiles.Length > 1)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Specify which project file to use because this '{projectDirectory}' contains more than one project file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return projectFiles[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ using Microsoft.DotNet.ProjectModel;
|
||||||
using Microsoft.DotNet.Tools.Common;
|
using Microsoft.DotNet.Tools.Common;
|
||||||
using Microsoft.Extensions.DependencyModel;
|
using Microsoft.Extensions.DependencyModel;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
using NuGet.LibraryModel;
|
|
||||||
using NuGet.ProjectModel;
|
using NuGet.ProjectModel;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
using FileFormatException = Microsoft.DotNet.ProjectModel.FileFormatException;
|
using FileFormatException = Microsoft.DotNet.ProjectModel.FileFormatException;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue