0

I also seem to not be able to figure out what using statement to use at the top of my file.

The nuget package is here: https://www.nuget.org/packages/csharp-extensions The method I'm trying to use from it is Object#Send

so, I call

<#objectInstanec>.Send("SomeMethod")

but the compiler says that the method is not defined on type object.
Send is defined here though: https://github.com/NullVoxPopuli/csharp-extensions/blob/master/Extensions/Methods.cs#L26

I've tried various using statements:

using csharp_extensions.Extensions.Methods;
using csharp_extensions.Extensions;
using csharp_extensions

none seem to work (csharp_extensions doesn't exist)

UPDATE - how I install the package

my project.json:

{
    "dependencies": {
        "System.Reflection": "4.1.0-beta-*",
        "Microsoft.Extensions.PlatformAbstractions": "(1.0.0-rc1-final,]",
        "xunit": "2.1.0-*",
        "xunit.runner.dnx": "2.1.0-*",
        "csharp-extensions": "1.0.1"
    },
    "commands": {
        "test": "xunit.runner.dnx"
    },
    "frameworks": {
        "dnxcore50": {
            "_": "this is the recommended windows runtime",
            "dependencies": {
                "System.Console": "4.0.0-beta-*",
                "System.Reflection": "4.1.0-beta-*",
                "System.Reflection.TypeExtensions": "4.1.0-beta-*",
                "System.Runtime.Extensions": "(4.0,]",
                "System.IO": "(4.0,]",
                "csharp-extensions": "1.0.1"

            }
        }
    }
}

and then I install the dependencies via

dnu restore

NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352

1 Answers1

1

Your NuGet package does not look correct to me. Your assemblies are in bin\Debug\dnxcore50. I would take a look at the NuGet documentation or download an existing NuGet package that works.

NuGet v2 style packages contain the assemblies inside lib directories. The directory inside the lib directory is named after the target framework. Taking a look at the Microsoft.Extensions.PlatformAbstractions NuGet package you have an assembly inside both the directories:

lib\net451
lib\dotnet5.4

So with your NuGet package I believe the assemblies are not being referenced since they are not in the correct directory. The dotnet5.4 directory has the assembly that can be used with the dnxcore target framework.

Also, the project.json should look like this (without system.reflection, as it's redundant)

{
    "dependencies": {
        "Microsoft.Extensions.PlatformAbstractions": "(1.0.0-rc1-final,]",
        "System.Reflection": "4.1.0-beta-*",
        "xunit": "2.1.0-*",
        "xunit.runner.dnx": "2.1.0-*"
    },
    "commands": {
        "run": "csharp_extensions",
        "test": "xunit.runner.dnx"
    },
    "frameworks": {
        "dnxcore50": {
            "_": "this is the recommended windows runtime",
            "dependencies": {
                "System.Console": "4.0.0-beta-*",
                "System.Reflection.TypeExtensions": "4.1.0-beta-*",
                "System.Runtime.Extensions": "(4.0,]",
                "System.Dynamic.Runtime": "(4.0.0,]",
                "Microsoft.CSharp": "(4.0.0,]",
                "System.IO": "(4.0,]"
            }
        }
    }
}
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • is there a way to modify the package.json to build to those directories? – NullVoxPopuli Dec 07 '15 at 18:58
  • I think you can just run `dnu pack` in the directory where your project.json is. At least that works for me with a ASP.NET 5 Class Library project. That creates a .nupkg with a lib directory. The directories inside have different names (lib\dnxcore50 and lib\dnx451) but I believe NuGet will recognise these. – Matt Ward Dec 07 '15 at 19:07
  • after I try the `NuGet Push `, I get this error now: `'csharp-extensions' already has a dependency defined for 'System.Reflection'` what does that mean? – NullVoxPopuli Dec 08 '15 at 12:27
  • looks like in addition to dnu pack, I had to also remove some dependencies from my project.json. – NullVoxPopuli Dec 08 '15 at 15:33