Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve runtime and native assets from dependency context of a class library #6718

Closed
natemcmaster opened this issue Aug 5, 2016 · 6 comments

Comments

@natemcmaster
Copy link
Contributor

I am attempting to solve the problem of creating an AssemblyLoadContext from a class library project (dotnet/efcore#5320) with only 3 inputs: dependency context, nuget package directory, and application base path. (NB: no project context)

Problem

The build trims "runtimeTargets" from the deps.json file. In order to execute code from an ALC, we need all runtime and native assets.

Steps to reproduce

Create and compile netstandard project

public class Class1 {}
{
    "dependencies": {
        "System.Data.SqlClient": "4.1.0"
    },
    "frameworks": {
        "netstandard1.3": {}
    }
}

Expected

  "runtime.native.System.Data.SqlClient.sni/4.0.0": {
        "dependencies": {
          "runtime.win7-x64.runtime.native.System.Data.SqlClient.sni": "4.0.1",
          "runtime.win7-x86.runtime.native.System.Data.SqlClient.sni": "4.0.1"
        }
      },
      "runtime.win7-x64.runtime.native.System.Data.SqlClient.sni/4.0.1": {
        "runtimeTargets": {
          "runtimes/win7-x64/native/sni.dll": {
            "rid": "win7-x64",
            "assetType": "native"
          }
        }
      },
      "runtime.win7-x86.runtime.native.System.Data.SqlClient.sni/4.0.1": {
        "runtimeTargets": {
          "runtimes/win7-x86/native/sni.dll": {
            "rid": "win7-x86",
            "assetType": "native"
          }
        }
      },

Actual

      "runtime.native.System.Data.SqlClient.sni/4.0.0": {
        "dependencies": {
          "runtime.win7-x64.runtime.native.System.Data.SqlClient.sni": "4.0.1",
          "runtime.win7-x86.runtime.native.System.Data.SqlClient.sni": "4.0.1"
        }
      },

      "runtime.win7-x64.runtime.native.System.Data.SqlClient.sni/4.0.1": {},
      "runtime.win7-x86.runtime.native.System.Data.SqlClient.sni/4.0.1": {},

cc @davidfowl

@jcansdale
Copy link

I think I might be bumping into the same issue here:
jcansdale/TestDriven.Net-Issues#7

Have you had any luck creating an AssemblyLoadContext? I hit a bug in that when trying to find a workaround for the above issue.

@natemcmaster
Copy link
Contributor Author

@jcansdale I've had success in creating a fully working AssemblyLoadContext from Microsoft.DotNet.ProjectModel.ProjectContext and from NuGet.ProjectModel.LockFile, but not from Microsoft.Extensions.DependencyModel.DependencyContext. I'm trying to create a tool that is project-model agnostic, but so far have found that DependencyContext doesn't provide enough information on class library projects.

@jcansdale
Copy link

I'd be interested to see your AssemblyLoadContext code if you have it checked in anywhere. 😄

@natemcmaster
Copy link
Contributor Author

@jcansdale Checkout https://github.com/dotnet/cli/tree/rel/1.0.0/src/Microsoft.DotNet.ProjectModel.Loader for making a load context from Microsoft.DotNet.ProjectModel.ProjectContext. Bear in mind this only works on the "project.json" project system. I have not yet successfully implemented a version that works with the project system work happening on https://github.com/microsoft/msbuild/tree/xplat or one that is project-system agnostic.

@jcansdale
Copy link

That's great, thanks. It's good to some real world usage of AssemblyLoadContext.

@natemcmaster natemcmaster changed the title Cannot resolve runtimeand native assets from dependency context of a class library Cannot resolve runtime and native assets from dependency context of a class library Aug 10, 2016
@TheRealPiotrP
Copy link
Contributor

Moved to core-setup to keep close to dependencycontext.

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants