Skip to content

Commit 6df176e

Browse files
committed
Build as netstandard for all but .NET Core
1 parent 179229c commit 6df176e

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

example/example.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@
33
<TargetFrameworks>netcoreapp31;netstandard20</TargetFrameworks>
44
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
55
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
8+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
9+
<PrivateAssets>all</PrivateAssets>
10+
</PackageReference>
11+
</ItemGroup>
612
</Project>

tests/test_common.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,47 @@
55

66

77
@pytest.fixture(scope="session")
8-
def example_dll(tmpdir_factory):
9-
out = str(tmpdir_factory.mktemp("example"))
8+
def example_netstandard(tmpdir_factory):
9+
return build_example(tmpdir_factory, "netstandard20")
10+
11+
@pytest.fixture(scope="session")
12+
def example_netcore(tmpdir_factory):
13+
return build_example(tmpdir_factory, "netcoreapp31")
14+
15+
def build_example(tmpdir_factory, framework):
16+
out = str(tmpdir_factory.mktemp(f"example-{framework}"))
1017
proj_path = os.path.join(os.path.dirname(__file__), "../example")
1118

12-
check_call(["dotnet", "build", proj_path, "-o", out, "-f", "netcoreapp31"])
19+
check_call(["dotnet", "build", proj_path, "-o", out, "-f", framework])
1320

1421
return out
1522

1623

1724
@pytest.mark.xfail
18-
def test_mono(example_dll):
25+
def test_mono(example_netstandard):
1926
from clr_loader import get_mono
2027

2128
mono = get_mono()
22-
asm = mono.get_assembly(os.path.join(example_dll, "example.dll"))
29+
asm = mono.get_assembly(os.path.join(example_netstandard, "example.dll"))
2330

2431
run_tests(asm)
2532

2633

27-
def test_coreclr(example_dll):
34+
def test_coreclr(example_netcore):
2835
from clr_loader import get_coreclr
2936

30-
coreclr = get_coreclr(os.path.join(example_dll, "example.runtimeconfig.json"))
31-
asm = coreclr.get_assembly(os.path.join(example_dll, "example.dll"))
37+
coreclr = get_coreclr(os.path.join(example_netcore, "example.runtimeconfig.json"))
38+
asm = coreclr.get_assembly(os.path.join(example_netcore, "example.dll"))
3239

3340
run_tests(asm)
3441

3542

3643
@pytest.mark.skipif(sys.platform != 'win32', reason=".NET Framework only exists on Windows")
37-
def test_netfx(example_dll):
44+
def test_netfx(example_netstandard):
3845
from clr_loader import get_netfx
3946

4047
netfx = get_netfx()
41-
asm = netfx.get_assembly(os.path.join(example_dll, "example.dll"))
48+
asm = netfx.get_assembly(os.path.join(example_netstandard, "example.dll"))
4249

4350
run_tests(asm)
4451

0 commit comments

Comments
 (0)