Skip to content

Issues loading types when mixing and matching net8.0 and netstandard2.1 #523

@njlr

Description

@njlr

A binary:

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_binary")

fsharp_binary(
  name = "app",
  srcs = [
    "Program.fs",
  ],
  target_frameworks = [
    "net8.0",
  ],
  deps = [
    "@paket.main//fsharp.core",
    "@paket.main//awssdk.core",
    "@paket.main//awssdk.s3",
    "//utils",
  ],
  treat_warnings_as_errors = True,
)

And a library:

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_library")

fsharp_library(
  name = "utils",
  srcs = [
    "Utils.fs",
  ],
  target_frameworks = [
    "netstandard2.1",
  ],
  deps = [
    "@paket.main//fsharp.core",
    "@paket.main//awssdk.core",
    "@paket.main//awssdk.s3",
  ],
  treat_warnings_as_errors = True,
  visibility = [
    "//visibility:public",
  ],
)

Leads to this runtime exception:

Unhandled exception. System.TypeLoadException: Virtual static method 'CreateDefaultClientConfig' is not implemented on type 'Amazon.DynamoDBv2.AmazonDynamoDBClient' from assembly 'AWSSDK.DynamoDBv2, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'.

If the targets are aligned, then it will work:

load("@rules_dotnet//dotnet:defs.bzl", "fsharp_library")

fsharp_library(
  name = "utils",
  srcs = [
    "Utils.fs",
  ],
  target_frameworks = [
-    "netstandard2.1",
+   "net8.0",
  ],
  deps = [
    "@paket.main//fsharp.core",
    "@paket.main//awssdk.core",
    "@paket.main//awssdk.s3",
  ],
  treat_warnings_as_errors = True,
  visibility = [
    "//visibility:public",
  ],
)

Issue appears with rules_dotnet versions 0.20.5 and 0.21.5.

Full repro here: https://github.com/njlr/rules_dotnet_aws_repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions