Converting a project to PCL & .NET Core gives CS0433 Error

173 Views Asked by At

I've taken an existing project https://github.com/cskardon/Neo4jClient/ and attempting to port to dotnet core as peeps are asking for this.

So far - I've added a PCL project (uwp, dnxcore50, net46) and a shared project - shifted all the code to the shared project, and then moved the 'Full' stuff (like Transaction.Scope to a Neo4jClient.Full project. So I have (at present):

  • Neo4jClient (PCL)
  • Neo4jClient.Full
  • Neo4jClient.Shared

(On Github here: https://github.com/cskardon/Neo4jClient/tree/Test-Portable)

I have the code all compiling, I'm fully aware that I've got missing functionality - but at present I'm interested in seeing if I can get this to work in a console app generated via yo aspnet in VS Code.

So I generate a nuget package and put in my local nuget store (also - if you want to try yourself: https://www.myget.org/F/cskardon/api/v3/index.json) add it to my project.json, which looks like:

{
  "version": "1.0.0-*",
  "description": "TestNeo4jClient Console Application",
  "authors": [ "" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "compilationOptions": {
    "emitEntryPoint": true
  },

  "tooling": {
    "defaultNamespace": "TestNeo4jClient"
  },

  "dependencies": {
      "Neo4jClient" : "2.0.0-PortableAlpha00001"
  },

  "commands": {
    "TestNeo4jClient": "TestNeo4jClient"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Console": "4.0.0-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }
}

dnu restore - all ok

dnu build gives these errors:

  • ApplyProjectInfo.cs(1,29): DNX,Version=v4.5.1 error CS0433: The type 'AssemblyDescriptionAttribute' exists in both 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  • D:\projects\VsCode\TestNeo4jClient\Program.cs(8,18): DNX,Version=v4.5.1 error CS0518: Predefined type 'System.Object' is not defined or imported

The project.json for the PCL project looks like:

{
  "supports": {
    "net46.app": {},
    "uwp.10.0.app": {},
    "dnxcore50.app": {}
  },
  "dependencies": {
    "Microsoft.NETCore": "5.0.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.0",
    "Newtonsoft.Json": "8.0.2",
    "NuSpec.ReferenceGenerator": "1.4.2",
    "System.Collections.NonGeneric": "4.0.0",
    "System.ComponentModel": "4.0.0",
    "System.ComponentModel.TypeConverter": "4.0.0",
    "System.Runtime.Serialization.Primitives": "4.0.10"
  },
  "frameworks": {
    "dotnet": {
      "imports": "portable-net452+win81"
    }
  }
}

I presume that I've got the PCL project.json wrong - but I am at a loss as to how.

PS. The nuspec file looks like:

  <dependencies>
    <group targetFramework="dotnet">
      <dependency id="Microsoft.CSharp" version="4.0.0" />
      <dependency id="Microsoft.VisualBasic" version="10.0.0" />
      <dependency id="Newtonsoft.Json" version="8.0.2" />
      <dependency id="System.Collections" version="4.0.10" />
      <dependency id="System.Collections.NonGeneric" version="4.0.0" />
      <dependency id="System.ComponentModel" version="4.0.0" />
      <dependency id="System.ComponentModel.Annotations" version="4.0.10" />
      <dependency id="System.ComponentModel.TypeConverter" version="4.0.0" />
      <dependency id="System.Diagnostics.Debug" version="4.0.10" />
      <dependency id="System.Dynamic.Runtime" version="4.0.10" />
      <dependency id="System.Globalization" version="4.0.10" />
      <dependency id="System.IO" version="4.0.10" />
      <dependency id="System.Linq" version="4.0.0" />
      <dependency id="System.Linq.Expressions" version="4.0.10" />
      <dependency id="System.Net.Http" version="4.0.0" />
      <dependency id="System.Net.Primitives" version="4.0.10" />
      <dependency id="System.Reflection" version="4.0.10" />
      <dependency id="System.Reflection.Extensions" version="4.0.0" />
      <dependency id="System.Reflection.TypeExtensions" version="4.0.0" />
      <dependency id="System.Resources.ResourceManager" version="4.0.0" />
      <dependency id="System.Runtime" version="4.0.20" />
      <dependency id="System.Runtime.Extensions" version="4.0.10" />
      <dependency id="System.Runtime.Serialization.Primitives" version="4.0.10" />
      <dependency id="System.Text.Encoding" version="4.0.10" />
      <dependency id="System.Text.RegularExpressions" version="4.0.10" />
      <dependency id="System.Threading" version="4.0.10" />
      <dependency id="System.Threading.Tasks" version="4.0.10" />
    </group>
  </dependencies>
</metadata>
<files>
  <file src="Neo4jClient.Full\bin\Release\Neo4jClient.dll" target="lib\net45" />
  <file src="Neo4jClient.Full\bin\Release\Neo4jClient.pdb" target="lib\net45" />
  <file src="Neo4jClient.Full\bin\Release\Neo4jClient.xml" target="lib\net45" />
  <file src="Neo4jClient\bin\Release\Neo4jClient.dll" target="lib\portable-net46+uwp10.0+dnxcore50" />
  <file src="Neo4jClient\bin\Release\Neo4jClient.pdb" target="lib\portable-net46+uwp10.0+dnxcore50" />
  <file src="Neo4jClient\bin\Release\Neo4jClient.xml" target="lib\portable-net46+uwp10.0+dnxcore50" />
  <file src="Neo4jClient\bin\Release\Neo4jClient.dll" target="lib\dotnet" />
  <file src="Neo4jClient\bin\Release\Neo4jClient.pdb" target="lib\dotnet" />
  <file src="Neo4jClient\bin\Release\Neo4jClient.xml" target="lib\dotnet" />
</files>
1

There are 1 best solutions below

1
On BEST ANSWER

At this point with the DNU tooling deprecated, I wouldn't spend a lot of time until RC2 ships. The dotnet CLI and netstandard will hopefully clear a lot of this mess up.