Skip to content

project.json and AnyCPU Classic Desktop projects #904

@bricelam

Description

@bricelam

I was playing around with the Microsoft.Data.Sqlite package after this pull request: aspnet/Microsoft.Data.Sqlite#100

The nupkg looks something like tihs:

  • Microsoft.Data.Sqlite
    • lib
      • dotnet
        • Microsoft.Data.Sqlite.dll
    • runtimes
      • win
        • native
          • x86
            • sqlite3.dll
          • x64
            • sqlite3.dll
      • (other RIDs)

I was trying to consume the package in a Full .NET AnyCPU project. (e.g. a WPF, WinForms, or Console app)

In theory, both the x86 and x64 directories (i.e. everything under runtimes/win/native) should be copied to the bin folder. The managed library could then call LoadLibrary(Path.Combine(bin, arch, "sqlite3.dll")); to load the appropriate library. Unfortunately, the directory structure isn't preserved. Both dlls are copied directly into the bin folder--one over top of the other.

I created a new Console app, added a project.json, and tried to install the package, but it gave the following error. It looks like instead of just using win for AnyCPU projects, it's trying to use win-anycpu.

C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets(76,5): error : Couldn't find the required information in the lock file. Make sure you have .NETFramework,Version=v4.6/win-anycpu mentioned in your targets.

I was able to resolve this using the following project.json file.

{
  "frameworks": {
    "net46": { }
  },
  "runtimes": {
    "win": { },
    "win-anycpu": {
      "#import": [ "win" ]
    }
  },
  "dependencies": {
    "Microsoft.Data.Sqlite": "1.0.0-*"
  }
}

/cc @rowanmiller @divega

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions