NuKeeperDotNet / NuKeeper

Automagically update nuget packages in .NET projects
Apache License 2.0
541 stars 128 forks source link

NuKeeper throws UriFormatException on execution. #739

Closed MaxMommersteeg closed 5 years ago

MaxMommersteeg commented 5 years ago

🐛 Bug Report

Since latest release the Azure DevOps extension outputs following exception when running NuKeeper:

Unhandled Exception: System.UriFormatException: Invalid URI: The URI is empty.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at NuKeeper.Gitea.GiteaSettingsReader.CanRead(Uri repositoryUri) in /home/vsts/work/r1/a/drop/NuKeeper.Gitea/GiteaSettingsReader.cs:line 36
   at NuKeeper.Commands.RepositoryCommand.PopulateSettings(SettingsContainer settings) in /home/vsts/work/r1/a/drop/NuKeeper/Commands/RepositoryCommand.cs:line 51
   at NuKeeper.Commands.CommandBase.OnExecute() in /home/vsts/work/r1/a/drop/NuKeeper/Commands/CommandBase.cs:line 88
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass142_0.<OnExecute>b__0()
   at NuKeeper.Program.Main(String[] args) in /home/vsts/work/r1/a/drop/NuKeeper/Program.cs:line 33

Could have something to do with recently added support for Gitea, looking at the exception? I posted this here since I suspect this will also fail from a manual NuKeeper run.

Expected behavior

Package being updated.

Reproduction steps

Run NuKeeper from Azure DevOps extension with following params: -v detailed -c Major -i (MSTest|Microsoft.NET.Test.Sdk|Microsoft.TestPlatform.TestHost) -n

Configuration

Version: 0.20.2

Platform if applicable:

MarcBruins commented 5 years ago

That's bad could you have a look @sharpsteff?

sharpSteff commented 5 years ago

yes

MarcBruins commented 5 years ago

Not sure if it's from your PR. Could also be from the github target branch PR.

sharpSteff commented 5 years ago

at NuKeeper.Gitea.GiteaSettingsReader.CanRead(Uri repositoryUri) in /home/vsts/work/r1/a/drop/NuKeeper.Gitea/GiteaSettingsReader.cs:line 36

I catched only HttpRequestException in the CanRead. Did not think about UriFormatExceptions

MarcBruins commented 5 years ago

Scratch that. It's weird that it now picks Gitea as the platform. It should pick azuredevops.. not sure what is going on here. The settingsreader of gitea returns that it can read a local azuredevops repo

sharpSteff commented 5 years ago

could reproduce the exception with a little unit test

public void CanRead_NoException_OnBadUri()
        {
            Assert.DoesNotThrow(() => _giteaSettingsReader.CanRead(new Uri("")));
        }
MarcBruins commented 5 years ago

Good, can you make a PR for that?

sharpSteff commented 5 years ago

yes on the way

sharpSteff commented 5 years ago

i like the automatic link to my commit

MarcBruins commented 5 years ago

Awesome, thanks for the quick help. Your pr and #744 should fix this issue.

sharpSteff commented 5 years ago

yes think so, too.

MarcBruins commented 5 years ago

Fix is released(https://github.com/NuKeeperDotNet/NuKeeper/releases) version 0.20.3 should now be available. Can you confirm that it work @MaxMommersteeg?

MaxMommersteeg commented 5 years ago

Sure, testing in a minute.

MaxMommersteeg commented 5 years ago

The execution failed again, but because of a different reason. Currently on mobile and not able to copy the exact exception message. Maybe tomorrow. This exact issue is fixed.

MarcBruins commented 5 years ago

Seems to work fine with me including the new formating

MaxMommersteeg commented 5 years ago

Getting following output:

[command]C:\agents\agent1\_work\_tool\dncs\2.2.202\x64\dotnet.exe C:\agents\agent1\_work\_temp\nukeeper\tools\netcoreapp2.1\any\NuKeeper.dll repo C:\agents\agent1\_work\10\s ******** --targetBranch origin/master -v detailed -c Major -i (MSTest|Microsoft.NET.Test.Sdk|Microsoft.TestPlatform.TestHost) -n
Matched uri 'https://fudura.visualstudio.com/' to collaboration platform 'AzureDevOps'
FindPushFork. Fork Mode is SingleRepositoryOnly
2019-04-20T07:33:35Z: Started
Attempting delete of folder C:\agents\agent1\_work\_temp\NuKeeper\package
Deleted folder C:\agents\agent1\_work\_temp\NuKeeper\package
Attempting delete of folder C:\agents\agent1\_work\_temp\NuKeeper\tools

Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'C:\agents\agent1\_work\_temp\NuKeeper\tools\netcoreapp2.1\any\LibGit2Sharp.dll' is denied.
   at System.IO.FileSystem.DeleteFile(String fullPath)
   at System.IO.File.Delete(String path)
   at NuKeeper.Inspection.Files.Folder.DeleteDirectoryInternal(String targetDir) in /home/vsts/work/r1/a/drop/NuKeeper.Inspection/Files/Folder.cs:line 68
   at NuKeeper.Inspection.Files.Folder.DeleteDirectoryInternal(String targetDir) in /home/vsts/work/r1/a/drop/NuKeeper.Inspection/Files/Folder.cs:line 74
   at NuKeeper.Inspection.Files.Folder.DeleteDirectoryInternal(String targetDir) in /home/vsts/work/r1/a/drop/NuKeeper.Inspection/Files/Folder.cs:line 74
   at NuKeeper.Inspection.Files.Folder.TryDelete() in /home/vsts/work/r1/a/drop/NuKeeper.Inspection/Files/Folder.cs:line 45
   at NuKeeper.Inspection.Files.FolderFactory.DeleteExistingTempDirs() in /home/vsts/work/r1/a/drop/NuKeeper.Inspection/Files/FolderFactory.cs:line 44
   at NuKeeper.Collaboration.CollaborationEngine.Run(SettingsContainer settings) in /home/vsts/work/r1/a/drop/NuKeeper/Collaboration/CollaborationEngine.cs:line 35
   at NuKeeper.Commands.CollaborationPlatformCommand.Run(SettingsContainer settings) in /home/vsts/work/r1/a/drop/NuKeeper/Commands/CollaborationPlatformCommand.cs:line 116
   at NuKeeper.Commands.CommandBase.OnExecute() in /home/vsts/work/r1/a/drop/NuKeeper/Commands/CommandBase.cs:line 96
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass142_0.<OnExecute>b__0()
   at NuKeeper.Program.Main(String[] args) in /home/vsts/work/r1/a/drop/NuKeeper/Program.cs:line 33
##[debug]task result: Failed
##[error]Error: The process 'C:\agents\agent1\_work\_tool\dncs\2.2.202\x64\dotnet.exe' failed with exit code 3762504530

Not sure why this fails, since I didn't make any changes to NuKeeper nor authentication or authorization areas.

MarcBruins commented 5 years ago

Can you open a new one with that info? This might be confusing for other people.

MaxMommersteeg commented 5 years ago

Sure, will do tomorrow

MaxMommersteeg commented 5 years ago

Created new issue.