Skip to content

Commit

Permalink
Fix error NU5030: The license file 'LICENSE' does not exist in the pa…
Browse files Browse the repository at this point in the history
…ckage.

Context https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5030#issue

When the filename of the license file has no extension
NuGet reports an error.

```
error NU5030: The license file 'LICENSE' does not exist in the package.
```

Even though we have the `PackagePath` set. According
to the error page, the `PackagePath` in these cases
should be empty.

To fix this we need to split out the `LicenceName` tag into
two values so that they can be set independently. So
we add `LicenceNamePackagePath` tag so that we can do so.
Existing code should behave the same way.
  • Loading branch information
dellis1972 committed Feb 23, 2024
1 parent 896218b commit 9e6a88b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Resources/MonoGame.Library.X.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<None Include="{LicencePath}" Pack="true" PackagePath="{LicenceName}" />
<None Include="{LicencePath}" Pack="true" PackagePath="{LicencePackagePath}" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions Tasks/PublishPackageTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ public override async Task RunAsync(BuildContext context)
projectData = projectData.Replace("{LicencePath}", context.PackContext.LicensePath);

if (context.PackContext.LicensePath.EndsWith(".txt"))
projectData = projectData.Replace("{LicenceName}", "LICENSE.txt");
projectData = projectData.Replace("{LicenceName}", "LICENSE.txt").Replace ("{LicencePackagePath}", "LICENSE.txt");
else if (context.PackContext.LicensePath.EndsWith(".md"))
projectData = projectData.Replace("{LicenceName}", "LICENSE.md");
projectData = projectData.Replace("{LicenceName}", "LICENSE.md").Replace ("{LicencePackagePath}", "LICENSE.md");
else if (context.PackContext.LicensePath.EndsWith ("LICENSE"))
// https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5030#issue
projectData = projectData.Replace("{LicenceName}", "LICENSE").Replace ("{LicencePackagePath}", "");
else
projectData = projectData.Replace("{LicenceName}", "LICENSE");
projectData = projectData.Replace("{LicenceName}", "LICENSE").Replace ("{LicencePackagePath}", "LICENSE");

var librariesToInclude = from rid in requiredRids from filePath in Directory.GetFiles($"runtimes/{rid}/native")
select $"<Content Include=\"{filePath}\"><PackagePath>runtimes/{rid}/native</PackagePath></Content>";
Expand Down

0 comments on commit 9e6a88b

Please sign in to comment.