diff --git a/dotnet/AxInterop.MSTSCLib/AxInterop.MSTSCLib.csproj b/dotnet/AxInterop.MSTSCLib/AxInterop.MSTSCLib.csproj index fc1d4e7..952ea9d 100644 --- a/dotnet/AxInterop.MSTSCLib/AxInterop.MSTSCLib.csproj +++ b/dotnet/AxInterop.MSTSCLib/AxInterop.MSTSCLib.csproj @@ -3,13 +3,21 @@ AxInterop.MSTSCLib + AxInterop.MSTSCLib + 1.0.0.0 Library true disable - False + True $(CMakeOutputPath) + + + <_Parameter1>11/09/2021 16:17:20 + + + True diff --git a/dotnet/AxInterop.MSTSCLib/Properties/AssemblyInfo.cs b/dotnet/AxInterop.MSTSCLib/Properties/AssemblyInfo.cs deleted file mode 100644 index 362f9d5..0000000 --- a/dotnet/AxInterop.MSTSCLib/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Windows.Forms; - -[assembly: AxHost.TypeLibraryTimeStamp("11/09/2021 16:17:20")] -[assembly: AssemblyVersion("1.0.0.0")] diff --git a/dotnet/AxInterop.MSTSCLib/RdpAxHost.cs b/dotnet/AxInterop.MSTSCLib/RdpAxHost.cs index 401ee7d..8f6a70d 100644 --- a/dotnet/AxInterop.MSTSCLib/RdpAxHost.cs +++ b/dotnet/AxInterop.MSTSCLib/RdpAxHost.cs @@ -147,7 +147,7 @@ public static string RdpGetAxDllPath(string axName) public static object RdpGetClassObject(Guid clsid, string axName, string rdpExDll) { - object? obj = null; + object obj = null; lock (loadLock) { diff --git a/dotnet/Devolutions.MsRdpEx/Devolutions.MsRdpEx.csproj b/dotnet/Devolutions.MsRdpEx/Devolutions.MsRdpEx.csproj index 916134e..7eff792 100644 --- a/dotnet/Devolutions.MsRdpEx/Devolutions.MsRdpEx.csproj +++ b/dotnet/Devolutions.MsRdpEx/Devolutions.MsRdpEx.csproj @@ -13,7 +13,7 @@ $(CMakeOutputPath) enable True - False + True diff --git a/dotnet/Interop.MSTSCLib/Interop.MSTSCLib.dll b/dotnet/Interop.MSTSCLib/Interop.MSTSCLib.dll index a3bebb1..072efec 100644 Binary files a/dotnet/Interop.MSTSCLib/Interop.MSTSCLib.dll and b/dotnet/Interop.MSTSCLib/Interop.MSTSCLib.dll differ diff --git a/scripts/SetAssemblyTargetFramework.ps1 b/scripts/SetAssemblyTargetFramework.ps1 new file mode 100644 index 0000000..865bb77 --- /dev/null +++ b/scripts/SetAssemblyTargetFramework.ps1 @@ -0,0 +1,71 @@ +param( + [string] $AssemblyFilePath, + [string] $FrameworkName = ".NETFramework,Version=v4.8", + [string] $FrameworkDisplayName = ".NET Framework 4.8" +) + +if (-Not (Test-Path $AssemblyFilePath)) { + throw "Assembly file not found at the specified path: $AssemblyFilePath" +} + +$ilasm = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ilasm.exe" +$ildasm = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\ildasm.exe" + +if (-Not (Test-Path $ilasm)) { + throw "ilasm.exe not found at the path: $ilasm" +} + +if (-Not (Test-Path $ildasm)) { + throw "ildasm.exe not found at the path: $ildasm" +} + +if (-Not (Get-Command -Name 'rg' -ErrorAction SilentlyContinue)) { + throw "rg (RipGrep) not found" +} + +$AssemblyName = [System.IO.Path]::GetFileNameWithoutExtension($AssemblyFilePath) +$AssemblyDllFile = $AssemblyFilePath +$AssemblyIlfile = "${AssemblyName}.il" +$AssemblyResfile = "${AssemblyName}.res" +& $ildasm "/OUT=$AssemblyIlfile" /NOBAR $AssemblyDllFile + +# https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.targetframeworkattribute + +# 01 00 +# 1A (26) +# 2E 4E 45 54 46 72 61 6D 65 77 6F 72 6B 2C 56 65 72 73 69 6F 6E 3D 76 34 2E 38 ".NETFramework,Version=v4.8" +# 01 00 54 0E +# 14 (20) +# 46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C 61 79 4E 61 6D 65 "FrameworkDisplayName" +# 12 (18) +# 2E 4E 45 54 20 46 72 61 6D 65 77 6F 72 6B 20 34 2E 38 ".NET Framework 4.8" + +function Convert-StringToByteArray { + param( + [Parameter(Mandatory=$true,Position=0)] + [string] $InputString + ) + + if ($InputString.Length -gt 255) { + throw "String length exceeds the maximum limit for a single byte." + } + + $lengthByte = [byte]$InputString.Length + $utf8Bytes = [System.Text.Encoding]::UTF8.GetBytes($InputString) + return , $lengthByte + $utf8Bytes +} + +$ctorBytes = @(0x01, 0x00) +$ctorBytes = $ctorBytes + (Convert-StringToByteArray $FrameworkName) +$ctorBytes = $ctorBytes + @(0x01, 0x00, 0x54, 0x0E) +$ctorBytes = $ctorBytes + (Convert-StringToByteArray "FrameworkDisplayName") +$ctorBytes = $ctorBytes + (Convert-StringToByteArray $FrameworkDisplayName) +$ctorHex = ($ctorBytes | ForEach-Object { $_.ToString("X2") }) -join " " + +$lineToAdd = " .custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = ( $CtorHex )" +$lineAfter = " .hash algorithm" +$NewContent = rg "$lineAfter" $AssemblyIlfile -r "$lineToAdd`r`n$lineAfter" -N --passthru +Set-Content -Path $AssemblyIlfile -Value $NewContent -Force + +& $ilasm $AssemblyIlfile "/OUTPUT=$AssemblyDllfile" /DLL "/RESOURCE=$AssemblyResfile" +@($AssemblyIlfile, $AssemblyResfile) | Remove-Item -Force -ErrorAction SilentlyContinue