Import package with .NET framework dependency

A package I want to share uses ports which are not accessible by default in unity. You have to change the API compatibility in the player settings to enable the namespace.

I tried writing a script which changes the settings automatically, but that script doesn’t run because unity throws an error about my scripts trying to use ports in the first place.

I don’t want to force users to change the settings themselves.

Is there a way I can configure my package to have the player settings changed before unity imports my scripts?

I’ve found a workaround. I included conditional compilation flags in the code to supress the error:

#if NET_4_6
// Code here
#endif

Apologies for this. I’ve had this issue in the past and could never find a workaround!