Execute net tools plugins#6113
Execute net tools plugins#6113Nigusu-Allehu merged 16 commits intodev-feature-dot-net-tool-plugin-supportfrom
Conversation
donnie-msft
left a comment
There was a problem hiding this comment.
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
jgonz120
left a comment
There was a problem hiding this comment.
Looks good to me, I think a new name for IsRunnablePluginFile would be good though.
|
|
||
| // Assert | ||
| Assert.Single(plugins); | ||
| Assert.False(plugins[0].IsDotnetToolsPlugin); |
There was a problem hiding this comment.
What does the value return now?
There was a problem hiding this comment.
The property has been renamed to RequiresDotnetHost and it returns environment based value. It would be false if it is desktop and true otherwise.
| 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.
Is there a test to validate this scenario?
There was a problem hiding this comment.
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.
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
outputPathto check if the plugin has been executed or not. The assert contain statement checks ifoutputPathcontainsFile executedwhich 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
debugLogPathif you would like to see what the plugin has been receiving and sending)set env variables as follows
Add a break point in
PluginManager.csat 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 = SuccessPR Checklist
Document .net tools Plugin feature Home#13858