Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget from portable class library: Value cannot be null or an empty string. Parameter name: profileValue

What I have

I have Portable Class Library MyProj.Backend.Contracts.csproj with following

project.json:

{
  "supports": {
    "net46.app": {},
    "uwp.10.0.app": {},
    "dnxcore50.app": {}
  },
  "dependencies": {
    "Microsoft.NETCore": "5.0.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.0",
    "NuSpec.ReferenceGenerator": "1.4.2"
  },
  "frameworks": {
    "dotnet": {
      "imports": "portable-net452+win81"
    }
  }
}

and nuspec:

<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>MyProj.Backend.Contracts</id>
    <version>1.0.0</version>
    <dependencies>
      <group targetFramework="dotnet">
        <dependency id="System.Resources.ResourceManager" version="4.0.0" />
        <dependency id="System.Runtime" version="4.0.20" />
      </group>
  </metadata>
</package>

Notice, that I've added NuSpec.ReferenceGenerator to my project, that added '' to my project json.

However, I'm still not able to pack my PCL library:

 nuget pack MyProj.Backend.Contracts.csproj

  Attempting to build package from 'MyProj.Backend.Contracts.csproj'.
  Packing files from 'C:\Projects\MyProj\Backend\Contracts\Dev\bin\Contracts'.
  Using ''MyProj.Backend.Contracts.csproj.nuspec' for metadata.
  Value cannot be null or an empty string.
  Parameter name: profileValue

What I need

How to modify my .nuspec so I can create package from my PCL library project?

like image 960
Liero Avatar asked Jan 15 '16 13:01

Liero


1 Answers

This is an issue with the new project.json and specifying dependencies. The error message is pretty bad but there is some guidance on how to make this work here: https://github.com/ericstj/NuGetDocs/blob/ericstj/nuget3samples/NuGet.Docs/Create/nuget3-packages-walkthrough.md

The short answer seems to be to use the Nuget package nuspec.referencegenerator to fill out the nuspec file correctly for you.

Just to add in reference to the comments below; with Nuget 3.3 (haven't tested with 3.4 or higher), mixing csproj and project.json files just doesn't seem to work (or it only works for a subset of scenarios). If you want to use a project.json you seem to need to use the new json project format for code files, or vice versa revert to a standard nuspec and csproj combination.

like image 58
Lex Avatar answered Oct 15 '22 01:10

Lex