chocolatey / package-validator

Windows service to validate packages conform to package standards
Apache License 2.0
31 stars 29 forks source link

"Part URI is empty." error when using LICENSE file without .txt extension #190

Open vors opened 5 years ago

vors commented 5 years ago

That took me couple hours to figure out and I read much more nuget code then I wanted to. So here it is.

If you try to use the LICENSE file instead of LICENSE.txt (which suppose to be a valid option according to https://github.com/chocolatey/package-validator/wiki/LicenseFileMissing )

Please add the a file named LICENSE.txt. You can see the format for that file if you call choco new test and look at the generated file in test\tools\LICENSE.txt

This check also looks for LICENSE, LICENSE.md, NOTICE.txt, NOTICE, and NOTICE.md. Casing doesn't matter for validation.

Then when running choco pack you will get a cryptic error (here is --debug output)

Sending message 'PostRunMessage' out if there are subscribers...
Chocolatey had an error occur:
System.ArgumentException: Part URI is empty.
   at System.IO.Packaging.PackUriHelper.CreatePartUri(Uri partUri)
   at NuGet.PackageBuilder.CreatePart(Package package, String path, Stream sourceStream)
   at NuGet.PackageBuilder.WriteFiles(Package package)
   at NuGet.PackageBuilder.Save(Stream stream)
   at chocolatey.infrastructure.app.nuget.NugetPack.BuildPackage(PackageBuilder builder, IFileSystem fileSystem, String outputPath)
   at chocolatey.infrastructure.app.services.NugetService.pack_run(ChocolateyConfiguration config)
   at chocolatey.infrastructure.app.services.ChocolateyPackageService.pack_run(ChocolateyConfiguration config)
   at chocolatey.infrastructure.app.runners.GenericRunner.run(ChocolateyConfiguration config, Container container, Boolean isConsole, Action`1 parseArgs)
   at chocolatey.infrastructure.app.runners.ConsoleApplication.run(String[] args, ChocolateyConfiguration config, Container container)
   at chocolatey.console.Program.Main(String[] args)
Exiting with 1
ferventcoder commented 4 years ago

@vors are you putting a link in the nuspec? You can't do that for internal files yet.

vors commented 4 years ago

I don't quite remember all the context - I wish I'd capture more at the time :) If I recall correctly, what happened in the package is that originally we only had a url link to the license. Then choco acceptance tests indicate that LICENSE file is missing. So I added it to the package (url is still present) and encountered this error. It was resolved by changing the name of the file to LICENSE.txt (url is still present).