-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute net tools plugins #6113
Execute net tools plugins #6113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nits for now. I'll review more later today
test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/PluginFactoryTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nits!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I think a new name for IsRunnablePluginFile would be good though.
@@ -525,7 +525,6 @@ public void GetPluginsInNuGetPluginPaths_NuGetPluginPathsPointsToAFileThatDoesNo | |||
|
|||
// Assert | |||
Assert.Single(plugins); | |||
Assert.False(plugins[0].IsDotnetToolsPlugin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the value return now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property has been renamed to RequiresDotnetHost
and it returns environment based value. It would be false if it is desktop and true otherwise.
@@ -240,7 +245,7 @@ internal List<PluginFile> GetPluginsInPath() | |||
} | |||
else | |||
{ | |||
pluginFiles.Add(new PluginFile(path, new Lazy<PluginFileState>(() => PluginFileState.InvalidFilePath))); | |||
pluginFiles.Add(new PluginFile(path, new Lazy<PluginFileState>(() => PluginFileState.InvalidFilePath), isRunnablePluginFile: false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test to validate this scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt we don’t need a test specifically for this scenario, as it would end up testing the behavior of PathValidator.IsValidLocalPath
and PathValidator.IsValidUncPath
within the if statement. Since the else case only triggers if both methods return false, testing this would indirectly validate PathValidator
’s internal logic, which I felt isn’t necessary for this context.
d883a09
into
dev-feature-dot-net-tool-plugin-support
Bug
Fixes: NuGet/Home#13741
Description
This PR makes sure plugins discovered in #5990 are executed. The plugin files are directly executed by starting a new process.
Unit test
The test case I wrote has a simple batch file with the following content
It is passed as a plugin file to the PluginFactory. The test looks into the contents of
outputPath
to check if the plugin has been executed or not. The assert contain statement checks ifoutputPath
containsFile executed
which should be written only if the plugin file has been executed.nuget-plugin-bat.bat
If you would like to manually test the plugin I used for testing, here it is as a file. : https://github.com/Nigusu-Allehu/NuGetBatAuthPlugin/blob/main/nuget-plugin-bat.bat (Edit the file and change the value of
debugLogPath
if you would like to see what the plugin has been receiving and sending)set env variables as follows
Add a break point in
PluginManager.cs
at the linevar utilities = await PerformOneTimePluginInitializationAsync(plugin, cancellationToken);
When the execution stops at this break point take a look into the values of the plugin variable. It should have a valueplugin.Connection.State = Success
PR Checklist
Document .net tools Plugin feature Home#13858