Aspnetcore: Package naming conventions -

Created on 30 Mar 2016  路  16Comments  路  Source: dotnet/aspnetcore

Since this issue has benn closed #874 I've posted new one, as the naming convention leads into dead end with 3rd party libs in extreme cases.

I am not able to use sap connector with ASP.NET Core 1.0, the error is;

The package ID 'sapnco_utils' contains invalid characters. Examples of valid package IDs include 'MyPackage' and 'MyPackage.Sample'.

And it occurs while publishing.

I am referencing it following way;

      "dependencies": {
        "rscp4n": "1.0.0-*",
        "SAPExtractorDotNET": "1.0.0-*",
        "SapIntegration": "1.0.0-*",
        "sapnco": "1.0.0-*"
      },

sapnco internally uses sapnco_utils
image

Can anyone give me some clue how to solve the issue?

By the way forcing developers to use particular name conventions by making errors isn't the best approach is it? Shouldn't it be displayed as a warning?

Most helpful comment

If they are using dnx, the fix is to use dotnet-cli :smile:

All 16 comments

@marcingolenia I may be completely off based here, but it seems that recent changes to NuGet and/or .NET Core are now enforcing this constraint.

I'm sure the teams will figure out an easier workaround since SAP is not the only 3rd party that has chosen to add an "_" in their package name but may I suggest something...

Have you tried warpping each of those DLLs in their own .NET Core project using "bin syntax" and then referencing each project?

@marcingolenia What version of the CLI are you running? I just created a dotnet new project using the latest CLI, took on a NuGet dependency that has an invalid naming convention and was able to run dotnet publish on OS X without any error:

project.json

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },
    "dependencies": {
        "Google.Apis.Admin.Reports.reports_v1": "1.11.1.316",
        "Microsoft.NETCore.App": {
            "type": "platform",
            "version": "1.0.0-rc2-23929"
        }
    },
    "frameworks": {
        "netstandard1.5": {
            "imports": [
                "portable-net45+win8",
                "dnxcore50"
            ]
        }
    }
}

If this is an issue with dotnet-cli, please log an issue at https://github.com/dotnet/cli/issues/. Ultimately that's what's reading the project.json file. It might end up being a NuGet issue, but dotnet-cli is a good place to start.

@Eilon Agreed., But for the record, I'm assuming @marcingolenia is using dotnet-cli he never described his enviornment, he may very well be using dnx.

If they are using dnx, the fix is to use dotnet-cli :smile:

Hi again,
we are using DNX. Sorry for misleading you - much is happening with OpenSource .NET recently. I've read a bit and it turned out that DNX is used for ASP5 only, .NetCore 1.0 has it's own CLI. Correct?

I didn't know about the bin syntax - I will give it a try and let you know. Thanks for all the information!

@marcingolenia Actually, considering your screenshot shows the offending dependency (sapnco_utils) is pulled in by depending on sapnco _and_ you only see this when running dnx publish I'd imagine the bin syntax won't help much.

Might be worth giving the CLI a go - especiallly now that it's a _little_ more stable. Good luck!

I'm working with @marcingolenia, Silly thing is that it works on local machine, allows debugging in VS etc. But you cannot publish it... Is there any way to publish it (or deploy to another machine) using different tool?
This project is not big - it's web api requires connection to SAP. How can we migrate to dotnet-cli? I've tried to find something, but changing framework in project.json just gives us a bunch of 'package not found / not compatible with framework' errors.

@Nooth You're probably missing feeds in your NuGet.config. Do you have a repo you can share? Or at the least post your project.json to this thread or a gist and I'll give it a shot.

The project.json looks like this right now;

{
  "version": "1.0.0-*",
  "authors": [ "x1darifi" ],
  "commands": {
    "ef": "EntityFramework.Commands"
  },
  "dependencies": {
    "Microsoft.Framework.DependencyInjection": "1.0.0-beta8",
    "Microsoft.Data.Services": "5.7.0-beta",
    "Microsoft.AspNet.Http.Abstractions": "1.0.0-beta8",
    "Autofac.Framework.DependencyInjection": "4.0.0-beta8-*",
    "Obea.DataModels.DNX": "1.0.0-*",
    "Dapper": "1.42.0",
    "Dapper.SimpleCRUD": "1.9.2",
    "Microsoft.CSharp": "4.0.0",
    "System.Linq": "4.0.0",
    "System.Reflection.TypeExtensions": "4.0.0",
    "EntityFramework.SqlServer": "7.0.0-beta8",
    "EntityFramework.Commands": "7.0.0-beta8"
  },
  "description": "Obea.DAL Class Library",
  "frameworks": {
    "dnx451": {
      "compilationOptions": {
        "define": [ "ASYNC" ],
        "warningsAsErrors": false
      },
      "dependencies": {
        "rscp4n": "1.0.0-*",
        "SAPExtractorDotNET": "1.0.0-*",
        "SapIntegration": "1.0.0-*",
        "sapnco": "1.0.0-*"
      },
      "frameworkAssemblies": {
        "System.Data": "",
        "System.Xml": ""
      }
    }
  },
  "licenseUrl": "",
  "projectUrl": "",
  "tags": [ "" ]
}

Can you let us know what are the correct steps to migrate to .NET Core 1.0?

  1. Should we replace "frameworks" json ? with;
    "frameworks": {
        "netstandard1.5": {
            "imports": [
                "portable-net45+win8",
                "dnxcore50"
            ]
        }
    }
  1. What with framework dependencies where we should put it know? Can you give as an example?
  2. In many places we are using 1.0.0-beta8 versions (with Solution DNX SDK version 1.0.0-beta8) Do we need to upgrade now?

Our current nuget feeds (yes we were missing some of them);

  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="aspvnext" value="https://www.myget.org/F/aspnetvnext/" />
    <add key="AspNet VNext" value="https://www.myget.org/F/aspnetmaster/api/v2/" />
    <add key="nuget.org 2" value="https://www.nuget.org/api/v2/" />
    <add key="myget.org dotnet-coreclr" value="https://www.myget.org/F/dotnet-coreclr/api/v3/index.json" />
    <add key="myget.org dotnet-core" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
    <add key="myget.org dotnet-corefxtestdata" value="https://www.myget.org/F/dotnet-corefxtestdata/api/v3/index.json" />
    <add key="myget.org dotnet-buildtools" value="https://www.myget.org/F/dotnet-buildtools/api/v3/index.json" />
  </packageSources>

Thank you for your time on this issue. I hope these conversation will be helpful for other people migrating from DNX.

@marcingolenia There's a lot involved in migrating a DNX application to .NET Core 1.0 and it may be worth waiting until RC2 drops before taking that on - especially if you have something working in DEV and your problem is just publishing.

Since your applciation is targeting dnx451 (and not dnxcore50) I'll assume one or more of your dependencies requires .NET full. Therefore, I took your project.json removed any project and 3rd party dependencies, ran it against both 1.0.0-rc1-update1 and the latest 1.0.0-rc2-20222 of DNX on my Mac with Mono and was able to restore, build, and pack with all of those -beta8 pinned versions. Furthermore, I was also able to restore, build, and publish using the latest dotnet-cli (1.0.0-beta-002171).

Since my main machine is a Mac I'll have to try and source those SAP components and actually try and recreate the problem you are running into on my Windows 10 VM but until then have you simply tried upgrading your DNX to the latest and see if you can pack?

Also, all of this worked with only the following feeds:

    <add key="aspnetcidev" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
    <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
    <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />

We did it. Now we are able to run dotnet restore/build/publish, however the last one outputs only dlls and "runtimes" folder which do not work with IIS, I was following;
https://docs.asp.net/en/latest/publishing/iis.html#install-the-http-platform-handler
But using dotnet publish instead of dnx publish.
All in all we are getting off the topic. Let's close the issue with solution;

use dotnet CLI from .NET Core 1 RC1.

Thank you for you support. If you know something about publishing to IIS please share with us :)

I have the same problem, is there already a solution for this?

@Rian0702

use dotnet CLI from .NET Core 1 RC1.

@MaximRouiller okay but as i understand this is a command line tool. I Cannot publish it with visual studio?

@Rian0702

From his post, he is publishing with the new dotnet-cli instead of DNX but with ASP.NET Core 1.0 RC1.

Have you tried that or are you publishing with DNX?

Was this page helpful?
0 / 5 - 0 ratings