diff --git a/.gitignore b/.gitignore index e40091a..7b0c234 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.vs /inidbi2/obj -/inidbi2/Properties /inidbi2/bin -/@inidbi2/Addons/inidbi2.pbo \ No newline at end of file +/@inidbi2/Addons/inidbi2.pbo +*.csproj.user +*.pubxml.user diff --git a/@inidbi2/README.txt b/@inidbi2/README.md similarity index 62% rename from @inidbi2/README.txt rename to @inidbi2/README.md index 3fe1cd5..5f8df98 100644 --- a/@inidbi2/README.txt +++ b/@inidbi2/README.md @@ -1,20 +1,35 @@ +# Updated readme: +Updated by [Avril112113](https://github.com/Avril112113) + +Updated to work on **both Windows and Linux**, since the old [inidbi2-linux](https://github.com/cmd-johnson/inidbi2-linux) port broke in an Arma 3 update. +It can load the old linux saves but might not work in certain cases. It will always save new data using the original windows format. (Both are using `.ini` but there was some minor difference which were incompatible) +Requires .NET 9, which at this time is in preview (It might work with .NET 8?) +Only x64 binaries are provided for both Windows and Linux, x86 builds aren't tested. + +Building requires to be run on that platform. +Windows: `dotnet publish -r win-x64` +Linux: `dotnet publish -r linux-x64` +Be weary of Linux distro versions, if built on newer Debian version, it will not work on an older one. +*Both binaries have changed, I haven't gone through the process of getting them approved by battle-eye, this is a non-issue for servers.* + +# Original readme: Description: INIDBI 2.06 - A simple server-side database extension using INI files Author: code34 nicolas_boiteux@yahoo.fr Copyright (C) 2013-2019 Nicolas BOITEUX - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/@inidbi2/inidbi2.dll b/@inidbi2/inidbi2.dll deleted file mode 100644 index 63bf75c..0000000 Binary files a/@inidbi2/inidbi2.dll and /dev/null differ diff --git a/@inidbi2/inidbi2_x64.dll b/@inidbi2/inidbi2_x64.dll index 3f5d4e4..f2e3684 100644 Binary files a/@inidbi2/inidbi2_x64.dll and b/@inidbi2/inidbi2_x64.dll differ diff --git a/@inidbi2/inidbi2_x64.so b/@inidbi2/inidbi2_x64.so new file mode 100644 index 0000000..d123d34 Binary files /dev/null and b/@inidbi2/inidbi2_x64.so differ diff --git a/README.txt b/README.md similarity index 62% rename from README.txt rename to README.md index 3fe1cd5..5f8df98 100644 --- a/README.txt +++ b/README.md @@ -1,20 +1,35 @@ +# Updated readme: +Updated by [Avril112113](https://github.com/Avril112113) + +Updated to work on **both Windows and Linux**, since the old [inidbi2-linux](https://github.com/cmd-johnson/inidbi2-linux) port broke in an Arma 3 update. +It can load the old linux saves but might not work in certain cases. It will always save new data using the original windows format. (Both are using `.ini` but there was some minor difference which were incompatible) +Requires .NET 9, which at this time is in preview (It might work with .NET 8?) +Only x64 binaries are provided for both Windows and Linux, x86 builds aren't tested. + +Building requires to be run on that platform. +Windows: `dotnet publish -r win-x64` +Linux: `dotnet publish -r linux-x64` +Be weary of Linux distro versions, if built on newer Debian version, it will not work on an older one. +*Both binaries have changed, I haven't gone through the process of getting them approved by battle-eye, this is a non-issue for servers.* + +# Original readme: Description: INIDBI 2.06 - A simple server-side database extension using INI files Author: code34 nicolas_boiteux@yahoo.fr Copyright (C) 2013-2019 Nicolas BOITEUX - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/inidbi2.sln b/inidbi2.sln index 250823b..2baafb9 100644 --- a/inidbi2.sln +++ b/inidbi2.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29009.5 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34525.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "inidbi2", "inidbi2\inidbi2.csproj", "{61C2DA60-03D6-422D-A741-3F36BC392AF4}" EndProject @@ -23,8 +23,8 @@ Global {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Debug|x86.Build.0 = Debug|x86 {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|Any CPU.ActiveCfg = Release|Any CPU {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|Any CPU.Build.0 = Release|Any CPU - {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|x64.ActiveCfg = Release|x64 - {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|x64.Build.0 = Release|x64 + {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|x64.ActiveCfg = Release|Any CPU + {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|x64.Build.0 = Release|Any CPU {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|x86.ActiveCfg = Release|x86 {61C2DA60-03D6-422D-A741-3F36BC392AF4}.Release|x86.Build.0 = Release|x86 EndGlobalSection diff --git a/inidbi2/Properties/PublishProfiles/linux-x64.pubxml b/inidbi2/Properties/PublishProfiles/linux-x64.pubxml new file mode 100644 index 0000000..efe77cf --- /dev/null +++ b/inidbi2/Properties/PublishProfiles/linux-x64.pubxml @@ -0,0 +1,17 @@ + + + + + Release + x64 + bin\Release\net8.0\publish\linux-x64 + FileSystem + <_TargetId>Folder + net8.0 + linux-x64 + true + false + + \ No newline at end of file diff --git a/inidbi2/Properties/PublishProfiles/win-x64.pubxml b/inidbi2/Properties/PublishProfiles/win-x64.pubxml new file mode 100644 index 0000000..9b11734 --- /dev/null +++ b/inidbi2/Properties/PublishProfiles/win-x64.pubxml @@ -0,0 +1,18 @@ + + + + + Release + x64 + bin\Release\net8.0\publish\win-x64\ + FileSystem + <_TargetId>Folder + net8.0 + win-x64 + true + false + false + + \ No newline at end of file diff --git a/inidbi2/Properties/PublishProfiles/win-x86.pubxml b/inidbi2/Properties/PublishProfiles/win-x86.pubxml new file mode 100644 index 0000000..c8dc2d1 --- /dev/null +++ b/inidbi2/Properties/PublishProfiles/win-x86.pubxml @@ -0,0 +1,18 @@ + + + + + Release + x86 + bin\Release\net8.0\publish\win-x64\ + FileSystem + <_TargetId>Folder + net8.0 + win-x86 + true + false + false + + \ No newline at end of file diff --git a/inidbi2/inidbi2.cs b/inidbi2/inidbi2.cs index 7f58a7e..5efd3f3 100644 --- a/inidbi2/inidbi2.cs +++ b/inidbi2/inidbi2.cs @@ -2,25 +2,37 @@ using System.IO; using System.Text; using System.Runtime.InteropServices; -using RGiesecke.DllExport; +using System.Runtime.CompilerServices; +using IniParser; +using IniParser.Model; using System.Reflection; +using System.Formats.Asn1; namespace inidbi2 { public class inidbi2 { #if WIN64 - [DllExport("RVExtension", CallingConvention = CallingConvention.Winapi)] + [UnmanagedCallersOnly(EntryPoint = "RVExtension", CallConvs = [typeof(CallConvStdcall)])] #else - [DllExport("_RVExtension@12", CallingConvention = CallingConvention.Winapi)] + // Untested + [UnmanagedCallersOnly(EntryPoint = "_RVExtension@12", CallConvs = [typeof(CallConvStdcall)])] #endif - public static void RVExtension(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function) + public unsafe static void RVExtension(byte* _output, uint outputSize, char* _function) { + string function = Marshal.PtrToStringAnsi((IntPtr)_function); + if (_instance == null) _instance = new inidbi2(); string ret = _instance.Invoke(function); - output.Append(ret); + + var len = Math.Min(ret.Length, outputSize); + var bytes = Encoding.ASCII.GetBytes(ret); + for (int i = 0; i < len; i++) { + _output[i] = bytes[i]; + } + _output[len] = 0; return; } @@ -34,54 +46,84 @@ public static string DebugRv(StringBuilder output, int outputSize, [MarshalAs(Un } static inidbi2 _instance; - static string[] stringSeparators = { "|" }; - - [DllImport("kernel32")] - private static extern int WritePrivateProfileString(string section, string key, string val, string filePath); - [DllImport("kernel32")] - private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); - [DllImport("kernel32")] - private static extern int GetPrivateProfileStruct(string section, string key, string struc, int size, string filepath); - [DllImport("kernel32")] - private static extern int WritePrivateProfileStruct(string section, string key, string struc, int size, string filepath); - [DllImport("kernel32")] - private static extern int GetPrivateProfileSectionNames(byte[] retVal, int size, string filePath); - [DllImport("kernel32")] - private static extern int GetPrivateProfileSection(string section, byte[] retVal, int size, string File); - [DllImport("kernel32")] - private static extern int GetLastError(); - - - public string Invoke(string parameters) { + static string[] stringSeparators = ["|"]; + FileIniDataParser parser = new(); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + private static extern uint GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, uint nSize); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + private static extern IntPtr GetModuleHandle(IntPtr lpModuleName); + + public static string GetDllPath() + { + StringBuilder path = new StringBuilder(260); // MAX_PATH in Windows + IntPtr handle = GetModuleHandle(IntPtr.Zero); // NULL gets the current module + GetModuleFileName(handle, path, (uint)path.Capacity); + return path.ToString(); + } + + [StructLayout(LayoutKind.Sequential)] + private struct Dl_info + { + public IntPtr dli_fname; + public IntPtr dli_fbase; + public IntPtr dli_sname; + public IntPtr dli_saddr; + } + + [DllImport("libdl.so.2")] + private static extern int dladdr(IntPtr addr, ref Dl_info info); + + public static string GetSoPath() + { + Dl_info info = new Dl_info(); + dladdr(Addr(), ref info); + return Marshal.PtrToStringAnsi(info.dli_fname); + } + + public static unsafe IntPtr Addr() + { + return (IntPtr)(delegate*)&Addr; + } + + + public string Invoke(string parameters) + { string[] lines = parameters.Split(stringSeparators, StringSplitOptions.None); - + string function = lines[0]; string result = ""; - string mypath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\db\\"; + string mypath; + if (OperatingSystem.IsWindows()) { + mypath = Path.Join(Path.GetDirectoryName(GetDllPath()), "db"); + } else { + mypath = Path.Join(Path.GetDirectoryName(GetSoPath()), "db"); + } + //Console.WriteLine($"DB Path: {mypath}"); - switch (function) - { + switch (function) { case "version": result = this.Version(); break; case "write": - result = this.Write(mypath + lines[1], lines[2], lines[3], lines[4]); + result = this.Write(Path.Join(mypath, lines[1]), lines[2], lines[3], lines[4]); break; case "read": - result = this.Read(mypath + lines[1], lines[2], lines[3]); + result = this.Read(Path.Join(mypath, lines[1]), lines[2], lines[3]); break; case "deletesection": - result = this.DeleteSection(mypath + lines[1], lines[2]); + result = this.DeleteSection(Path.Join(mypath, lines[1]), lines[2]); break; case "deletekey": - result = this.DeleteKey(mypath + lines[1], lines[2], lines[3]); + result = this.DeleteKey(Path.Join(mypath, lines[1]), lines[2], lines[3]); break; case "delete": - result = this.Delete(mypath + lines[1]); + result = this.Delete(Path.Join(mypath, lines[1])); break; case "exists": - result = this.Exists(mypath + lines[1]); + result = this.Exists(Path.Join(mypath, lines[1])); break; case "gettimestamp": result = this.GetTimeStamp(); @@ -99,10 +141,10 @@ public string Invoke(string parameters) { result = GetSeparator(); break; case "getsections": - result = GetSections(mypath + lines[1]); + result = GetSections(Path.Join(mypath, lines[1])); break; case "getkeys": - result = GetKeys(mypath + lines[1], lines[2]); + result = GetKeys(Path.Join(mypath, lines[1]), lines[2]); break; default: break; @@ -130,16 +172,12 @@ public string Version() public string Delete(string File) { string result = "true"; - try - { - if (!System.IO.File.Exists(File)) - { + try { + if (!System.IO.File.Exists(File)) { throw new Exception("File doesn't exist"); } System.IO.File.Delete(File); - } - catch - { + } catch { return "false"; } return result; @@ -147,73 +185,110 @@ public string Delete(string File) public string Exists(string File) { - return (System.IO.File.Exists(File)).ToString(); + return System.IO.File.Exists(File).ToString(); } public string Write(string File, string Section, string Key, string Value) { - if(WritePrivateProfileString(Section, Key, Value, File) == 0) {return "false";}else{return "true";} + try { + IniData data = System.IO.File.Exists(File) ? parser.ReadFile(File) : new IniData(); + if (!data.Sections.ContainsSection(Section)) + data.Sections.AddSection(Section); + data[Section][Key] = Value; + parser.WriteFile(File, data); + return "true"; + } catch (Exception e) { + Console.Error.WriteLine(e.ToString()); + return "false"; + } } public string Read(string File, string Section, string Key) { - StringBuilder temp = new StringBuilder(10230); - if(GetPrivateProfileString(Section, Key, "", temp, 10230, File) == 0) { return "[false, \"\"]"; } else { return "[true," + temp + "]"; } + try { + IniData data = System.IO.File.Exists(File) ? parser.ReadFile(File) : new IniData(); + if (!data.Sections.ContainsSection(Section) || !data[Section].ContainsKey(Key)) + return "[false, \"\"]"; + var s = data[Section][Key]; + // This might add compat with old Linux port? + if (s.StartsWith('"') && s.EndsWith('"')) + s = s[1..^1]; + return "[true, " + s + "]"; + } catch (Exception e) { + Console.Error.WriteLine(e.ToString()); + return "[false, \"\"]"; + } } public string DeleteSection(string File, string Section) { - if(WritePrivateProfileStruct(Section, null, null, 0, File) == 0) { return "false"; } else { return "true";} + try { + IniData data = System.IO.File.Exists(File) ? parser.ReadFile(File) : new IniData(); + bool ok = data.Sections.RemoveSection(Section); + if (ok) + parser.WriteFile(File, data); + return ok ? "true" : "false"; + } catch (Exception e) { + Console.Error.WriteLine(e.ToString()); + return "false"; + } } public string DeleteKey(string File, string Section, string key) { - if(WritePrivateProfileStruct(Section, key, null, 0, File) == 0) { return "false"; } else { return "true"; } + try { + IniData data = System.IO.File.Exists(File) ? parser.ReadFile(File) : new IniData(); + if (!data.Sections.ContainsSection(Section)) + return "false"; + bool ok = data[Section].RemoveKey(Section); + if (ok) + parser.WriteFile(File, data); + return ok ? "true" : "false"; + } catch (Exception e) { + Console.Error.WriteLine(e.ToString()); + return "false"; + } } public string GetSections(string File) { - byte[] temp = new byte[8000]; - int s = GetPrivateProfileSectionNames(temp, 8000, File); - String result = Encoding.Default.GetString(temp); - String[] names = result.Split('\0'); - result = "["; - foreach (String name in names) - { - if (name != String.Empty) - { - result = result + "\"" + name + "\","; + try { + IniData data = System.IO.File.Exists(File) ? parser.ReadFile(File) : new IniData(); + StringBuilder sb = new(); + sb.Append('['); + foreach (var sec in data.Sections) { + sb.Append('"'); + sb.Append(sec.SectionName); + sb.Append("\","); } + sb.Append(']'); + return sb.ToString(); + } catch (Exception e) { + Console.Error.WriteLine(e.ToString()); + return "[]"; } - if (result.Length > 1) - { - result = result.Remove(result.Length - 1, 1); - } - result = result + "]"; - return result; } public string GetKeys(string File, string section) { - byte[] temp = new byte[8000]; - int s = GetPrivateProfileSection(section, temp, 8000, File); - String result = Encoding.Default.GetString(temp); - String[] lines = result.Split('\0'); - result = "["; - foreach (String line in lines) - { - if (line != String.Empty) - { - string[] values = line.Split('='); - result = result + "\"" + values[0] + "\","; + try { + IniData data = System.IO.File.Exists(File) ? parser.ReadFile(File) : new IniData(); + if (!data.Sections.ContainsSection(section)) + return "[]"; + StringBuilder sb = new(); + sb.Append('['); + foreach (var key in data[section]) { + sb.Append('"'); + sb.Append(key.KeyName); + sb.Append("\","); } + sb.Append(']'); + return sb.ToString(); + } catch (Exception e) { + Console.Error.WriteLine(e.ToString()); + return "[]"; } - if(result.Length > 1 ) { - result = result.Remove(result.Length - 1, 1); - } - result = result + "]"; - return result; } public string GetTimeStamp() @@ -225,12 +300,10 @@ public string GetTimeStamp() public string EncodeBase64(string plainText) { string ret = ""; - try - { - var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); - ret = System.Convert.ToBase64String(plainTextBytes); - } catch - { + try { + var plainTextBytes = Encoding.UTF8.GetBytes(plainText); + ret = Convert.ToBase64String(plainTextBytes); + } catch { return ret; } return ret; @@ -239,12 +312,10 @@ public string EncodeBase64(string plainText) public string DecodeBase64(string base64EncodedData) { string ret = ""; - try - { - var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); - ret = System.Text.Encoding.UTF8.GetString(base64EncodedBytes); - } catch - { + try { + var base64EncodedBytes = Convert.FromBase64String(base64EncodedData); + ret = Encoding.UTF8.GetString(base64EncodedBytes); + } catch { return ret; } return ret; diff --git a/inidbi2/inidbi2.csproj b/inidbi2/inidbi2.csproj index fa03d4b..b21c15e 100644 --- a/inidbi2/inidbi2.csproj +++ b/inidbi2/inidbi2.csproj @@ -1,109 +1,57 @@ - - - + - Debug - AnyCPU - {61C2DA60-03D6-422D-A741-3F36BC392AF4} + net9.0 Library - Properties - inidbi2 - inidbi2 - v4.7.2 - 512 - - - - true - full - false - bin\debug\ - DEBUG;TRACE - prompt - 4 - x86 + True + win-x64;win-x86;linux-x64 + true + true + true + false + embedded + inidbi2 + true + true - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + TRACE;DEBUG;WIN64 x64 + inidbi2_x64 - true bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt MinimumRecommendedRules.ruleset bin\x86\Release\ - DEBUG;TRACE - true - pdbonly - x86 - prompt MinimumRecommendedRules.ruleset - true - - - false - true bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - true + TRACE;DEBUG;WIN64 + inidbi2_x64 + MinimumRecommendedRules.ruleset true bin\x64\Release\ TRACE;DEBUG;WIN64 - true - pdbonly - x64 - prompt + inidbi2_x64 MinimumRecommendedRules.ruleset + + + warnings + + + AnyCPU true - 4 - - ..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll - False - - - - - - - - - - - - - + + + - + - - - \ No newline at end of file diff --git a/inidbi2/packages.config b/inidbi2/packages.config deleted file mode 100644 index e004cb1..0000000 --- a/inidbi2/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/inidbi2_x64.dll b/inidbi2_x64.dll new file mode 100644 index 0000000..f2e3684 Binary files /dev/null and b/inidbi2_x64.dll differ diff --git a/inidbi2_x64.so b/inidbi2_x64.so new file mode 100644 index 0000000..d123d34 Binary files /dev/null and b/inidbi2_x64.so differ diff --git a/packages/UnmanagedExports.1.2.7/.signature.p7s b/packages/UnmanagedExports.1.2.7/.signature.p7s deleted file mode 100644 index 5d9d4e0..0000000 Binary files a/packages/UnmanagedExports.1.2.7/.signature.p7s and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/UnmanagedExports.1.2.7.nupkg b/packages/UnmanagedExports.1.2.7/UnmanagedExports.1.2.7.nupkg deleted file mode 100644 index 7d33d74..0000000 Binary files a/packages/UnmanagedExports.1.2.7/UnmanagedExports.1.2.7.nupkg and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/lib/net/RGiesecke.DllExport.Metadata.dll b/packages/UnmanagedExports.1.2.7/lib/net/RGiesecke.DllExport.Metadata.dll deleted file mode 100644 index bec9cf6..0000000 Binary files a/packages/UnmanagedExports.1.2.7/lib/net/RGiesecke.DllExport.Metadata.dll and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/tools/DllExportCmdLets.psm1 b/packages/UnmanagedExports.1.2.7/tools/DllExportCmdLets.psm1 deleted file mode 100644 index 481afac..0000000 --- a/packages/UnmanagedExports.1.2.7/tools/DllExportCmdLets.psm1 +++ /dev/null @@ -1,105 +0,0 @@ -function Remove-OldDllExportFolder { - param($project) - $defaultFiles = ('DllExportAttribute.cs', - 'Mono.Cecil.dll', - 'RGiesecke.DllExport.dll', - 'RGiesecke.DllExport.pdb', - 'RGiesecke.DllExport.MSBuild.dll', - 'RGiesecke.DllExport.MSBuild.pdb', - 'RGiesecke.DllExport.targets') - - $projectFile = New-Object 'System.IO.FileInfo'($project.FullName) - - $projectFile.Directory.GetDirectories("DllExport") | Select-Object -First 1 | % { - $dllExportDir = $_ - - if($dllExportDir.GetDirectories().Count -eq 0){ - $unknownFiles = $dllExportDir.GetFiles() | Select -ExpandProperty Name | ? { -not $defaultFiles -contains $_ } - - if(-not $unknownFiles){ - Write-Host "Removing 'DllExport' from " $project.Name - $project.ProjectItems | ? { $_.Name -ieq 'DllExport' } | % { - $_.Remove() - } - - Write-Host "Deleting " $dllExportDir.FullName " ..." - $dllExportDir.Delete($true) - } - } - } -} - -function Remove-OldDllExportFolders { - Get-Project -all | % { - Remove-OldDllExportFolder $_ - } -} - -function Get-DllExportMsBuildProjectsByFullName([String] $fullName) { - $msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'; - $msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name) - - if(!$msBuildV4) { - throw New-Object 'System.IO.FileNotFoundException'("Could not load $msBuildV4Name.") - } - - $projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection') - - return $projectCollection::GlobalProjectCollection.GetLoadedProjects($fullName) -} - -function Get-AllDllExportMsBuildProjects { - (Get-Project -all | % { - Get-DllExportMsBuildProjectsByFullName $_.FullName - }) | ? { - return ($_.Xml.Imports | ? { - "RGiesecke.DllExport.targets" -ieq [System.IO.Path]::GetFileName($_.Project); - }).Length -gt 0; - } -} - -function Assert-PlatformTargetOfProject([String] $fullName) { - $proj = Get-DllExportMsBuildProjectsByFullName $fullName - - if(!$proj) { - return; - } - - $platformTarget = $proj.GetPropertyValue('PlatformTarget'); - - if(!$platformTarget -or ($platformTarget -ine 'x86' -and $platformTarget -ine 'x64')) { - $projectName = [IO.Path]::GetFileNameWithoutExtension($fullName); - if(!$platformTarget) { - $platformTarget = "has no platform target"; - } else { - $platformTarget = "has a platform target of '$platformTarget'"; - } - Write-Warning "The project '$projectName' $platformTarget. Only x86 or x64 assemblies can export functions." - Write-Host "" - } -} - -function Set-NoDllExportsForAnyCpu([String] $projectName, [System.Nullable[bool]] $value) { - $projects = Get-AllDllExportMsBuildProjects; - - [String] $asString = $value; - - if($projectName) { - $projects = $projects | where { $_.Name -ieq $projectName }; - } - $propertyName = 'NoDllExportsForAnyCpu'; - - $projects = $projects | where { - $_.GetPropertyValue($propertyName) -ine $asString - } | % { - $_.SetProperty($propertyName, $asString); - } -} - -Export-ModuleMember Set-NoDllExportsForAnyCpu - -Export-ModuleMember Remove-OldDllExportFolder -Export-ModuleMember Remove-OldDllExportFolders -Export-ModuleMember Get-DllExportMsBuildProjectsByFullName -Export-ModuleMember Get-AllDllExportMsBuildProjects -Export-ModuleMember Assert-PlatformTargetOfProject \ No newline at end of file diff --git a/packages/UnmanagedExports.1.2.7/tools/Mono.Cecil.dll b/packages/UnmanagedExports.1.2.7/tools/Mono.Cecil.dll deleted file mode 100644 index 8cf15a1..0000000 Binary files a/packages/UnmanagedExports.1.2.7/tools/Mono.Cecil.dll and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.dll b/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.dll deleted file mode 100644 index ba22ab1..0000000 Binary files a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.dll and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.pdb b/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.pdb deleted file mode 100644 index 79a2a6c..0000000 Binary files a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.MSBuild.pdb and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.dll b/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.dll deleted file mode 100644 index 5a77fe7..0000000 Binary files a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.dll and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.pdb b/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.pdb deleted file mode 100644 index e0e571a..0000000 Binary files a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.pdb and /dev/null differ diff --git a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets b/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets deleted file mode 100644 index dd63ee1..0000000 --- a/packages/UnmanagedExports.1.2.7/tools/RGiesecke.DllExport.targets +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - $(PostBuildEventDependsOn); - RGieseckeDllExport - - - - - - $(BuildDependsOn); - RGieseckeDllExport - - - - - - - - - - - - RGiesecke.DllExport.DllExportAttribute - RGiesecke.DllExport.Metadata - - $(Platform) - $(PlatformTarget) - $(CpuType) - $(DebugSymbols) - false - $(DllExportTimeout) - $(KeyContainerName)$(AssemblyKeyContainerName) - $(KeyOriginatorFile) - $(MSBuildProjectDirectory) - $(TargetPath) - $(TargetedFrameworkDir);$(TargetFrameworkDirectory) - $(DevEnvDir)\..\..\VC\bin - $(DevEnvDir) - $(TargetFrameworkVersion) - $(TargetFrameworkSDKToolsDirectory) - $(NoDllExportsForAnyCpu) - - - - - \ No newline at end of file diff --git a/packages/UnmanagedExports.1.2.7/tools/init.ps1 b/packages/UnmanagedExports.1.2.7/tools/init.ps1 deleted file mode 100644 index 03ebad4..0000000 --- a/packages/UnmanagedExports.1.2.7/tools/init.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -Import-Module (Join-Path $toolsPath DllExportCmdLets.psm1) - -if($project) { - Assert-PlatformTargetOfProject $project.FullName -} -else { - Get-AllDllExportMsBuildProjects | % { - Assert-PlatformTargetOfProject $_.FullPath - } -} \ No newline at end of file diff --git a/packages/UnmanagedExports.1.2.7/tools/install.ps1 b/packages/UnmanagedExports.1.2.7/tools/install.ps1 deleted file mode 100644 index 3f4cefd..0000000 --- a/packages/UnmanagedExports.1.2.7/tools/install.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -$targetFileName = 'RGiesecke.DllExport.targets' -$targetFileName = [IO.Path]::Combine($toolsPath, $targetFileName) -$targetUri = New-Object Uri -ArgumentList $targetFileName, [UriKind]::Absolute - -$msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'; -$msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name) - -if(!$msBuildV4) { - throw New-Object System.IO.FileNotFoundException("Could not load $msBuildV4Name."); -} - -$projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection') - -# change the reference to RGiesecke.DllExport.Metadata.dll to not be copied locally - -$project.Object.References | ? { - $_.Name -ieq "RGiesecke.DllExport.Metadata" -} | % { - if($_ | Get-Member | ? {$_.Name -eq "CopyLocal"}){ - $_.CopyLocal = $false - } -} - -$projects = $projectCollection::GlobalProjectCollection.GetLoadedProjects($project.FullName) -$projects | % { - $currentProject = $_ - - # remove imports of RGiesecke.DllExport.targets from this project - $currentProject.Xml.Imports | ? { - return ("RGiesecke.DllExport.targets" -ieq [IO.Path]::GetFileName($_.Project)) - } | % { - $currentProject.Xml.RemoveChild($_); - } - - # remove the properties DllExportAttributeFullName and DllExportAttributeAssemblyName - $currentProject.Xml.Properties | ? { - $_.Name -eq "DllExportAttributeFullName" -or $_.Name -eq "DllExportAttributeAssemblyName" - } | % { - $_.Parent.RemoveChild($_) - } - - $projectUri = New-Object Uri -ArgumentList $currentProject.FullPath, [UriKind]::Absolute - $relativeUrl = $projectUri.MakeRelative($targetUri) - $import = $currentProject.Xml.AddImport($relativeUrl) - $import.Condition = "Exists('$relativeUrl')"; - - # remove the old stuff in the DllExports folder from previous versions, (will check that only known files are in it) - Remove-OldDllExportFolder $project - Assert-PlatformTargetOfProject $project.FullName -} \ No newline at end of file diff --git a/packages/UnmanagedExports.1.2.7/tools/uninstall.ps1 b/packages/UnmanagedExports.1.2.7/tools/uninstall.ps1 deleted file mode 100644 index cc535ae..0000000 --- a/packages/UnmanagedExports.1.2.7/tools/uninstall.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -$targetFileName = 'RGiesecke.DllExport.targets' -$targetFileName = [System.IO.Path]::Combine($toolsPath, $targetFileName) -$targetUri = New-Object Uri($targetFileName, [UriKind]::Absolute) - -$projects = Get-DllExportMsBuildProjectsByFullName($project.FullName) - -return $projects | % { - $currentProject = $_ - - $currentProject.Xml.Imports | ? { - "RGiesecke.DllExport.targets" -ieq [System.IO.Path]::GetFileName($_.Project) - } | % { - $currentProject.Xml.RemoveChild($_) - } -} \ No newline at end of file