I am trying to do create a nuget package by combining .nuspec and .csproj file.
My .csproj file looks like below:
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Authors>Author name</Authors>
<Company>Company name</Company>
<RepositoryUrl>RepositoryURL</RepositoryUrl>
<VersionPrefix>0.0.1</VersionPrefix>
<PackageId>SomeID</PackageId>
<Description>Description</Description>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<NuspecFile>Projectname.nuspec</NuspecFile>
</PropertyGroup>
My .nuspec file looks like following:
<?xml version="1.0"?>
<package>
<files>
<file src=" somefile.json" target="lib" />
</files>
</package>
Now, when I try dotnet pack
on .csproj file it fails with folllowing error:
The required element 'metadata' is missing from the manifest.
I have also tried couple of things here.
Tried to map properties explicitly as mentioned here:Unable to pack a NuGet package using dotnet CLI and nuspec file but it failed with the same errors
Tried to put explicit metadata
tag into the .nuspec file.
like <metadata>$PackageId</metadata>
hoping that it will fetch $package
from .csproj file but that fails with following error:
The required element 'id' is missing from the manifest.
How can I combine both .csproj and .nuspec to do dotnet pack
without running into this errors? I am pretty sure it is possible just that I am missing something.
Any suggestions?
The required element 'id' is missing from the manifest.
.nuspec has to have metadata
element. It would not build without it. While trying to combine .csproj and .nuspec make sure that the mandatory fields like
<Authors>Author name</Authors> <Company>Company name</Company> <VersionPrefix>0.0.1</VersionPrefix> <PackageId>SomeID</PackageId>
are always set in .nuspec. inside metadata tag Not in .csproj.