Skip to content

Commit

Permalink
feat(codeintel): Add new command line arguments for customizing dotne…
Browse files Browse the repository at this point in the history
…t restore (#69)
  • Loading branch information
mmanela authored Dec 13, 2024
1 parent dbbe7f7 commit 066d969
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
18 changes: 15 additions & 3 deletions ScipDotnet/IndexCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ namespace ScipDotnet;

public static class IndexCommandHandler
{
public static async Task<int> Process(IHost host, List<FileInfo> projects, string output, FileInfo workingDirectory,
List<string> include, List<string> exclude, bool allowGlobalSymbolDefinitions, int dotnetRestoreTimeout)
public static async Task<int> Process(
IHost host,
List<FileInfo> projects,
string output,
FileInfo workingDirectory,
List<string> include,
List<string> exclude,
bool allowGlobalSymbolDefinitions,
int dotnetRestoreTimeout,
bool skipDotnetRestore,
FileInfo? nugetConfigPath
)
{
var logger = host.Services.GetRequiredService<ILogger<IndexCommandOptions>>();
var matcher = new Matcher();
Expand All @@ -34,7 +44,9 @@ public static async Task<int> Process(IHost host, List<FileInfo> projects, strin
logger,
matcher,
allowGlobalSymbolDefinitions,
dotnetRestoreTimeout
dotnetRestoreTimeout,
skipDotnetRestore,
nugetConfigPath
);
await ScipIndex(host, options);
return 0;
Expand Down
4 changes: 3 additions & 1 deletion ScipDotnet/IndexCommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ public record IndexCommandOptions(
ILogger<IndexCommandOptions> Logger,
Matcher Matcher,
bool AllowGlobalSymbolDefinitions,
int DotnetRestoreTimeout
int DotnetRestoreTimeout,
bool SkipDotnetRestore,
FileInfo? NugetConfigPath
);
8 changes: 7 additions & 1 deletion ScipDotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ public static async Task<int> Main(string[] args)
"If enabled, allow public symbol definitions to be accessible from other SCIP indexes. " +
"If disabled, then public symbols will only be visible within the index."),
new Option<int>("--dotnet-restore-timeout", () => DotnetRestoreTimeout,
@"The timeout (in ms) for the ""dotnet restore"" command")
@"The timeout (in ms) for the ""dotnet restore"" command"),
new Option<bool>("--skip-dotnet-restore", () => false,
@"Skip executing ""dotnet restore"" and assume it has been run externally."),
new Option<FileInfo?>("--nuget-config-path", () => null,
@"Provide a case sensitive custom path for ""dotnet restore"" to find the NuGet.config file. " +
@"If not provided, ""dotnet restore"" will search for the NuGet.config file recursively up the folder hierarchy " +
@"and in the default user and system config locations."),
};
indexCommand.Handler = CommandHandler.Create(IndexCommandHandler.Process);
var rootCommand =
Expand Down
10 changes: 9 additions & 1 deletion ScipDotnet/ScipProjectIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public ScipProjectIndexer(ILogger<ScipProjectIndexer> logger) =>
private void Restore(IndexCommandOptions options, FileInfo project)
{
var arguments = project.Extension.Equals(".sln") ? $"restore {project.FullName} /p:EnableWindowsTargeting=true" : "restore /p:EnableWindowsTargeting=true";
if (options.NugetConfigPath != null)
{
arguments += $" --configfile \"{options.NugetConfigPath.FullName}\"";
}
var process = new Process()
{
StartInfo = new ProcessStartInfo()
Expand Down Expand Up @@ -55,7 +59,11 @@ private void Restore(IndexCommandOptions options, FileInfo project)
FileInfo rootProject,
HashSet<ProjectId> indexedProjects)
{
Restore(options, rootProject);
if (!options.SkipDotnetRestore)
{
Restore(options, rootProject);
}

var projects = (string.Equals(rootProject.Extension, ".csproj") || string.Equals(rootProject.Extension, ".vbproj")
? new[]
{
Expand Down

0 comments on commit 066d969

Please sign in to comment.