Multi Targeting between .net framework and .net core

I have multiple C# projects and SDKs that are built targeting the .NET 4.8 Framework. When we build our projects, we then copy all the contents of each project’s Bin/Debug folder to our pyRevit extension’s .extension/bin folder to ensure that any specific DLLs one project might need are included.

The issue we have now is that some of these .NET Framework DLLs are incompatible with .NET Core Revit and we’d need to provide both the .NET Framework and .NET 8 / .NET Core DLLs.

So far we noticed that the DLLs creating the problems are System.Diagnostics.DiagnosticSource and System.Text.Json.

My question is: Is it possible to modify the startup.cs and organize the bin folder to have a multi-targeting bin folder structure? i.e., inside of the bin folder you would also have /net472 and /net8.0. Or is there any other way to do so?

We would really prefer to only have to maintain one PyRevit extension and just have the startup.cs, or any other built-in mechanism, handle the targeting.

Is this multi-targeting idea part of the new PyRevit 6.0.0 version? https://github.com/pyrevitlabs/pyRevit/releases/tag/v6.0.0.26032%2B2145

1 Like

@romangolev @sanzoghenzo @dosymep It would be great to get your expert opinion on this

No one? Are we really the only people that encountered this? I can’t believe it :sweat_smile:

1 Like

I am actually doing sth like this:

import clr
from pyrevit import HOST_APP, script

if HOST_APP.is_older_than(2025):
     DLL_PATH = script.get_bundle_file("myblazingfastdllfor4.8.dll")
     clr.AddReference(DLL_PATH)
else:
     DLL_PATH = script.get_bundle_file("myblazingfastdllfor8.0.dll")
     clr.AddReferenceToFileAndPath(DLL_PATH)  # simply addreference doesn't work

from blazingfastdll import faststuff

But I think the correct way to do it would be to target .NET-Standard 2.0 which supports both. Haven’t tried that though.

2 Likes