Skip to content

Commit 1d4e8d9

Browse files
committed
Run dotnet restore when indexing a project
1 parent 858da4d commit 1d4e8d9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ScipDotnet/ScipIndexer.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using Microsoft.CodeAnalysis;
23
using Microsoft.CodeAnalysis.MSBuild;
34
using Microsoft.Extensions.DependencyInjection;
@@ -19,8 +20,25 @@ public ScipIndexer(ILogger<ScipIndexer> logger)
1920

2021
private ILogger<ScipIndexer> Logger { get; }
2122

23+
public void Restore(IndexCommandOptions options)
24+
{
25+
var process = new Process()
26+
{
27+
StartInfo = new ProcessStartInfo()
28+
{
29+
WorkingDirectory = options.WorkingDirectory.FullName,
30+
FileName = "dotnet",
31+
Arguments = options.ProjectsFile.FullName.EndsWith(".sln")
32+
? $"restore {options.ProjectsFile.FullName}"
33+
: "restore"
34+
}
35+
};
36+
process.Start();
37+
}
38+
2239
public async IAsyncEnumerable<Scip.Document> IndexDocuments(IHost host, IndexCommandOptions options)
2340
{
41+
Restore(options);
2442
IEnumerable<Project> projects = string.Equals(options.ProjectsFile.Extension, ".csproj")
2543
? new[]
2644
{

0 commit comments

Comments
 (0)