Search code examples
c#.netvisual-studiomsbuildnuget

NuGet Error NU5030 - The license file 'LICENSE.txt' does not exist in the package


I have an error in Visual Studio 17.5.1. My Visual Studio is up to date.

vs

The error

error

The license file "LICENSE.md" does not exists in the package. NuGet Error NU5030


My project file (.csproj)

The files are located in a parent folder. SolutionFolder/ProjectFolder

I tried

  1. From Microsoft NuGet Error NU5030 <None Include="../LICENSE.md" Pack="true" Visible="true" PackagePath="" />
  2. As it was before this error
<None Include="../LICENSE.md">
        <Pack>True</Pack>
        <PackagePath></PackagePath>
</None>
  1. 1 or 2. I copied the files in the same folder of project.

<None Include="LICENSE.md" Pack="true" Visible="true" PackagePath="" />

or

<None Include="LICENSE.md">
        <Pack>True</Pack>
        <PackagePath></PackagePath>
</None>
  1. <None Include="$(MSBuildThisFileDirectory)LICENSE.md" Pack="true" PackagePath="" />
  2. <None Include="$(SolutionDir)LICENSE.md" Pack="true" PackagePath="" />

Project.csproj

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <TargetFramework>net6.0</TargetFramework>
        <PackageId>$(AssemblyName)</PackageId>
        <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
        <PackageLicenseFile>License.md</PackageLicenseFile>
        <IncludeContentInPack>false</IncludeContentInPack>
        <VersionPrefix>27.0.0</VersionPrefix>
        <VersionSuffix></VersionSuffix>
        <Version>27.0.0</Version>
        <LangVersion>latest</LangVersion>
    </PropertyGroup>
    <ItemGroup>
        <None Include="License.md" Pack="true" PackagePath="" />
    </ItemGroup>
</Project>

Screenshots

fullcapture


Solution

  • Change IncludeContentInPack = true

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <Nullable>enable</Nullable>
            <ImplicitUsings>enable</ImplicitUsings>
            <TargetFramework>net6.0</TargetFramework>
            <PackageId>$(AssemblyName)</PackageId>
            <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
            <PackageLicenseFile>License.md</PackageLicenseFile>
    
             <IncludeContentInPack>true</IncludeContentInPack>
    
            <VersionPrefix>27.0.0</VersionPrefix>
            <VersionSuffix></VersionSuffix>
            <Version>27.0.0</Version>
            <LangVersion>latest</LangVersion>
        </PropertyGroup>
        <ItemGroup>
            <None Include="License.md">
                <Pack>true</Pack>
                <PackagePath></PackagePath>
                <Visible>True</Visible>
            </None>
        </ItemGroup>
    </Project>
    

    All 5 forms specified on this question works fine, after changing IncludeContentInPack = true.

    IncludeContentInPack = false, ignores to add any content when pack operation is executed. If content is not added, the license file does not exists in the nuget package(NuGet Error NU5030).