diff --git a/Mono.Addins.SetupProcess/Mono.Addins.SetupProcess.csproj b/Mono.Addins.SetupProcess/Mono.Addins.SetupProcess.csproj
new file mode 100644
index 00000000..8200891e
--- /dev/null
+++ b/Mono.Addins.SetupProcess/Mono.Addins.SetupProcess.csproj
@@ -0,0 +1,47 @@
+
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {303D2716-94AA-4067-8111-F478D26DFAFE}
+ Exe
+ Mono.Addins.SetupProcess
+ Mono.Addins.SetupProcess
+ True
+ ..\mono-addins.snk
+
+
+ true
+ full
+ false
+ ..\bin
+ DEBUG;
+ prompt
+ 4
+ true
+
+
+ true
+ ..\bin
+ prompt
+ 4
+ true
+
+
+
+
+
+
+
+
+
+
+ {91DD5A2D-9FE3-4C3C-9253-876141874DAD}
+ Mono.Addins
+
+
+
+
\ No newline at end of file
diff --git a/Mono.Addins.SetupProcess/Properties/AssemblyInfo.cs b/Mono.Addins.SetupProcess/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..6edd5dd1
--- /dev/null
+++ b/Mono.Addins.SetupProcess/Properties/AssemblyInfo.cs
@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("Mono.Addins.SetupProcess")]
+[assembly: AssemblyCopyright("Copyright (C) 2007 Novell, Inc (http://www.novell.com)")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/Mono.Addins.SetupProcess/SetupProcessTool.cs b/Mono.Addins.SetupProcess/SetupProcessTool.cs
new file mode 100644
index 00000000..65f00324
--- /dev/null
+++ b/Mono.Addins.SetupProcess/SetupProcessTool.cs
@@ -0,0 +1,75 @@
+//
+// SetupProcessTool.cs
+//
+// Author:
+// Marius Ungureanu
+//
+// Copyright (c) 2019 Microsoft Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.Addins.Database;
+
+namespace Mono.Addins.SetupProcess
+{
+ class SetupProcessTool
+ {
+ public static int Main (string [] args)
+ {
+ ProcessProgressStatus monitor = new ProcessProgressStatus (int.Parse (args [0]));
+
+ try {
+ string registryPath = Console.In.ReadLine ();
+ string startupDir = Console.In.ReadLine ();
+ string addinsDir = Console.In.ReadLine ();
+ string databaseDir = Console.In.ReadLine ();
+
+ AddinDatabase.RunningSetupProcess = true;
+ AddinRegistry reg = new AddinRegistry (registryPath, startupDir, addinsDir, databaseDir);
+
+ switch (args [1]) {
+ case "scan": {
+ string folder = args.Length > 2 ? args [2] : null;
+ if (folder.Length == 0) folder = null;
+
+ var context = new ScanOptions ();
+ context.Read (Console.In);
+ reg.ScanFolders (monitor, folder, context);
+ break;
+ }
+ case "pre-scan": {
+ string folder = args.Length > 2 ? args [2] : null;
+ if (folder.Length == 0) folder = null;
+ var recursive = bool.Parse (Console.In.ReadLine ());
+ reg.GenerateScanDataFilesInProcess (monitor, folder, recursive);
+ break;
+ }
+ case "get-desc":
+ var outFile = Console.In.ReadLine ();
+ reg.ParseAddin (monitor, args [2], outFile);
+ break;
+ }
+ } catch (Exception ex) {
+ monitor.ReportError ("Unexpected error in setup process", ex);
+ return 1;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/Mono.Addins.sln b/Mono.Addins.sln
index e33045ba..54bb8d3c 100644
--- a/Mono.Addins.sln
+++ b/Mono.Addins.sln
@@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Addins.MSBuild", "Mono
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Addins.GuiGtk3", "Mono.Addins.GuiGtk3\Mono.Addins.GuiGtk3.csproj", "{410A7DC9-E7DA-43E6-B592-93E2A344B660}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Addins.SetupProcess", "Mono.Addins.SetupProcess\Mono.Addins.SetupProcess.csproj", "{303D2716-94AA-4067-8111-F478D26DFAFE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugWin32|Any CPU = DebugWin32|Any CPU
@@ -209,6 +211,16 @@ Global
{FEC19BDA-4904-4005-8C09-68E82E8BEF6A}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
{FEC19BDA-4904-4005-8C09-68E82E8BEF6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEC19BDA-4904-4005-8C09-68E82E8BEF6A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.DebugWin32|Any CPU.ActiveCfg = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.DebugWin32|Any CPU.Build.0 = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.DebugNoGui|Any CPU.ActiveCfg = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.DebugNoGui|Any CPU.Build.0 = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.DebugGtk3|Any CPU.ActiveCfg = Debug|Any CPU
+ {303D2716-94AA-4067-8111-F478D26DFAFE}.DebugGtk3|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F109148D-849E-4044-8700-5E8EA0AB2476} = {7EFC0684-310E-417D-B8BD-5584C3F34BD5}
diff --git a/Mono.Addins/AssemblyInfo.cs b/Mono.Addins/AssemblyInfo.cs
index 7b050f17..8b5a9d05 100644
--- a/Mono.Addins/AssemblyInfo.cs
+++ b/Mono.Addins/AssemblyInfo.cs
@@ -23,6 +23,10 @@
"0400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4" +
"f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Addins.SetupProcess, PublicKey=00240000048000009400000006020000002400005253413100" +
+ "0400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
+ "3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4" +
+ "f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo("UnitTests, PublicKey=00240000048000009400000006020000002400005253413100" +
"0400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4" +
diff --git a/Mono.Addins/Mono.Addins.Database/SetupProcess.cs b/Mono.Addins/Mono.Addins.Database/SetupProcess.cs
index 0ae3a337..e3da3266 100644
--- a/Mono.Addins/Mono.Addins.Database/SetupProcess.cs
+++ b/Mono.Addins/Mono.Addins.Database/SetupProcess.cs
@@ -68,10 +68,15 @@ internal static void ExecuteCommand (IProgressStatus monitor, string registryPat
sb.Append (" \"").Append (arg1).Append ("\"");
Process process = new Process ();
-
- string asm = null;
+
+ string thisAsmDir = Path.GetDirectoryName (typeof (SetupProcess).Assembly.Location);
+ string asm;
+ if (Util.IsMono)
+ asm = Path.Combine (thisAsmDir, "Mono.Addins.SetupProcess.exe");
+ else
+ asm = Path.Combine (thisAsmDir, "Mono.Addins.SetupProcess.dll");
+
try {
- asm = CreateHostExe ();
if (!Util.IsMono)
process.StartInfo = new ProcessStartInfo (asm, sb.ToString ());
else {
@@ -107,91 +112,8 @@ internal static void ExecuteCommand (IProgressStatus monitor, string registryPat
} catch (Exception ex) {
Console.WriteLine (ex);
throw;
- } finally {
- if (asm != null) {
- try {
- File.Delete (asm);
- } catch { }
- }
}
}
-
- public static int Main (string [] args)
- {
- ProcessProgressStatus monitor = new ProcessProgressStatus (int.Parse (args [0]));
-
- try {
- string registryPath = Console.In.ReadLine ();
- string startupDir = Console.In.ReadLine ();
- string addinsDir = Console.In.ReadLine ();
- string databaseDir = Console.In.ReadLine ();
-
- AddinDatabase.RunningSetupProcess = true;
- AddinRegistry reg = new AddinRegistry (registryPath, startupDir, addinsDir, databaseDir);
-
- switch (args [1]) {
- case "scan": {
- string folder = args.Length > 2 ? args [2] : null;
- if (folder.Length == 0) folder = null;
-
- var context = new ScanOptions ();
- context.Read (Console.In);
- reg.ScanFolders (monitor, folder, context);
- break;
- }
- case "pre-scan": {
- string folder = args.Length > 2 ? args [2] : null;
- if (folder.Length == 0) folder = null;
- var recursive = bool.Parse (Console.In.ReadLine ());
- reg.GenerateScanDataFilesInProcess (monitor, folder, recursive);
- break;
- }
- case "get-desc":
- var outFile = Console.In.ReadLine ();
- reg.ParseAddin (monitor, args [2], args [3]);
- break;
- }
- } catch (Exception ex) {
- monitor.ReportError ("Unexpected error in setup process", ex);
- return 1;
- }
- return 0;
- }
-
- static string CreateHostExe ()
- {
- string file;
- string id;
- string fullFile;
- do {
- id = Guid.NewGuid ().ToString ().Replace ('-','_');
- file = id + ".exe";
- fullFile = Path.Combine (Path.GetTempPath (), file);
- } while (File.Exists (fullFile));
-
- AssemblyName aname = new AssemblyName ();
- aname.Name = id;
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Save, Path.GetTempPath ());
- ModuleBuilder mb = ab.DefineDynamicModule (aname.Name, file);
- TypeBuilder tb = mb.DefineType ("App", TypeAttributes.Public|TypeAttributes.Class);
-
- MethodBuilder fb = tb.DefineMethod("Main",
- MethodAttributes.Public |
- MethodAttributes.Static,
- typeof(int), new Type[] { typeof(string[]) });
-
- MethodInfo mi = typeof(SetupProcess).GetMethod ("Main", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
-
- ILGenerator ilg = fb.GetILGenerator();
- ilg.Emit (OpCodes.Ldarg_0);
- ilg.EmitCall (OpCodes.Call, mi, null);
- ilg.Emit (OpCodes.Ret);
-
- tb.CreateType();
- ab.SetEntryPoint (fb, PEFileKinds.WindowApplication);
- ab.Save (file);
- return fullFile;
- }
}
class ProcessFailedException: Exception
diff --git a/Test/UnitTests/UnitTests.csproj b/Test/UnitTests/UnitTests.csproj
index c0329a32..68cb5947 100644
--- a/Test/UnitTests/UnitTests.csproj
+++ b/Test/UnitTests/UnitTests.csproj
@@ -45,6 +45,10 @@
{A85C9721-C054-4BD8-A1F3-0227615F0A36}
Mono.Addins.Setup
+
+ {303D2716-94AA-4067-8111-F478D26DFAFE}
+ Mono.Addins.SetupProcess
+