toddams/RazorLight

System.UriFormatException: Invalid URI: The hostname could not be parsed.

junalmeida opened this issue · 2 comments

UriBuilder uri = new UriBuilder(location);

Facing this exception while testing with dotnet test on ubuntu-latest on Azure DevOps:
I still have no idea of the value that DefaultAssemblyDirectoryFormatter is passing to Uri from the Assembly, no idea which Assembly in this the loop.

System.UriFormatException: Invalid URI: The hostname could not be parsed.
  Stack Trace:
      at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at System.UriBuilder..ctor(String uri)
   at RazorLight.Compilation.DefaultAssemblyDirectoryFormatter.GetAssemblyDirectory(Assembly assembly)
   at RazorLight.Compilation.DefaultMetadataReferenceManager.<Resolve>b__12_2(Assembly p)
   at System.Linq.Enumerable.SelectArrayIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly, DependencyContext dependencyContext)
   at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly)
   at RazorLight.Compilation.RoslynCompilationService.EnsureOptions()
   at RazorLight.Compilation.RoslynCompilationService.get_ParseOptions()
   at RazorLight.Compilation.RoslynCompilationService.CreateSyntaxTree(SourceText sourceText)
   at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName)
   at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate)
   at RazorLight.Compilation.RazorTemplateCompiler.CompileAndEmitAsync(RazorLightProjectItem projectItem)
   at RazorLight.Compilation.RazorTemplateCompiler.OnCacheMissAsync(String templateKey)
   at RazorLight.EngineHandler.CompileTemplateAsync(String key)

The assembly directory depends on what framework you're using, among other things, like whether you bundled the entrypoint project into a single DLL solution or not. This isn't exactly a RazorLight question, though.

Closing since the issue template wasnt followed.