public LockFile GetLockFile(string projectPath, string outputPath) { // Run the restore command var dotNetRunner = new DotNetRunner(); var arguments = new[] { "restore", $"\"{projectPath}\"" }; _ = dotNetRunner.Run(Path.GetDirectoryName(projectPath), arguments); // Load the lock file var lockFilePath = Path.Combine(outputPath, "project.assets.json"); return(LockFileUtilities.GetLockFile(lockFilePath, NuGet.Common.NullLogger.Instance)); }
public DependencyGraphSpec GenerateDependencyGraph(string projectPath) { var dotNetRunner = new DotNetRunner(); var dgOutput = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); var arguments = new[] { "msbuild", $"\"{projectPath}\"", "/t:GenerateRestoreGraphFile", $"/p:RestoreGraphOutputPath={dgOutput}" }; var runStatus = dotNetRunner.Run(Path.GetDirectoryName(projectPath), arguments); if (runStatus.IsSuccess) { var dependencyGraphText = File.ReadAllText(dgOutput); return(new DependencyGraphSpec(JsonConvert.DeserializeObject <JObject>(dependencyGraphText))); } else { throw new Exception($"Unable to process the the project `{projectPath}. Are you sure this is a valid .NET Core or .NET Standard project type?" + $"\r\n\r\nHere is the full error message returned from the Microsoft Build Engine:\r\n\r\n" + runStatus.Output); } }