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

1

13

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?

Elnaelnar answered 15/1, 2016 at 13:19 Comment(0)
E
5

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.

Expunction answered 29/2, 2016 at 13:2 Comment(3)
I've tried to add this package and also play a little with my nuspec but I'm still getting the same errorElnaelnar
nuspec.referencegenerator is not supposed to make csproj packing to work. It helps to add dependencies to nuspec in each build or by command lineElnaelnar
While the situation may have changed for the recent 3.4 release, attempting to use a project.json with a csproj really doesn't seem to work. I tried for a cross platform package and reverted to the csproj and nuspec method. As far as I can see, if you want to use project.json you need to be using the new project format for your code files as well.Expunction

© 2022 - 2024 — McMap. All rights reserved.