예제 #1
0
        static IEnumerable <MonoRuntimeInfo> GetAllArchitecturesOfRuntimes(string dir)
        {
            var rinfo64 = new MonoRuntimeInfo(dir, true);
            var rinfo32 = new MonoRuntimeInfo(dir, false);

            if (rinfo64.IsValidRuntime && rinfo32.IsValidRuntime)
            {
                yield return(rinfo64);

                yield return(rinfo32);
            }
            else if (rinfo64.IsValidRuntime)
            {
                yield return(rinfo64);
            }
            else if (rinfo32.IsValidRuntime)
            {
                yield return(rinfo32);
            }
            else
            {
                var rinfo = new MonoRuntimeInfo(dir, null);
                if (rinfo.IsValidRuntime)
                {
                    yield return(rinfo);
                }
            }
        }
예제 #2
0
 internal MonoTargetRuntime(MonoRuntimeInfo info)
 {
     this.monoVersion     = info.MonoVersion;
     this.monoDir         = Path.Combine(Path.Combine(info.Prefix, "lib"), "mono");
     environmentVariables = info.GetEnvironmentVariables();
     monoRuntimeInfo      = info;
 }
예제 #3
0
        public static TargetRuntime RegisterRuntime(MonoRuntimeInfo info)
        {
            MonoTargetRuntime tr = new MonoTargetRuntime(info);

            Runtime.SystemAssemblyService.RegisterRuntime(tr);
            customRuntimes.Add(info);
            SaveRuntimes();
            return(tr);
        }
		void CreateCommandLineWithSolution (string fileName, MonoRuntimeInfo monoRuntimeInfo, bool isMonoRuntime)
		{
			var solution = new FakePackageManagementSolution ();
			solution.FileName = fileName;
			commandLine = new NuGetPackageRestoreCommandLine (
				solution,
				monoRuntimeInfo,
				isMonoRuntime);
		}
		public MonoPclCommandLine (
			MonoRuntimeInfo monoRuntime,
			bool isMonoRuntime)
		{
			this.monoRuntime = monoRuntime;
			this.isMonoRuntime = isMonoRuntime;

			List = true;
		}
		public NuGetPackageRestoreCommandLine (
			IPackageManagementSolution solution,
			MonoRuntimeInfo monoRuntime,
			bool isMonoRuntime)
		{
			this.monoRuntime = monoRuntime;
			this.isMonoRuntime = isMonoRuntime;

			GenerateCommandLine(solution);
			GenerateWorkingDirectory(solution);
		}
		public void CommandLine_RestoreSolutionOnMono_MonoUsedFromCurrentPrefix ()
		{
			var monoRuntime = new MonoRuntimeInfo (@"c:\Users\Prefix");
			CreateCommandLineWithSolution (@"d:\projects\MySolution\MySolution.sln", monoRuntime);

			string arguments = commandLine.Arguments;

			string expectedCommandLine = Path.Combine (@"c:\Users\Prefix", "bin", "mono");
			Assert.IsTrue (arguments.StartsWith ("--runtime=v4.0 "), arguments);
			Assert.IsTrue (arguments.EndsWith ("restore -NonInteractive \"d:\\projects\\MySolution\\MySolution.sln\""), arguments);
			Assert.AreEqual (expectedCommandLine, commandLine.Command);
		}
예제 #8
0
        public static MonoRuntimeInfo FromCurrentRuntime()
        {
            // Get the current mono version
            Type t = Type.GetType("Mono.Runtime");

            if (t == null)
            {
                return(null);
            }

            MonoRuntimeInfo rt = new MonoRuntimeInfo();

            // Since Mono 3.0.5/ee035e3eb463816a9590b09f65842503640c6337 GetDisplayName is public
            string ver = (string)t.InvokeMember("GetDisplayName", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, null, null, null);

            //not sure which version this old scheme applies to
            int i = ver.IndexOf("/branches/mono-");

            if (i != -1)
            {
                i += 15;
                int j = ver.IndexOf('/', i);
                if (j != -1)
                {
                    rt.monoVersion = ver.Substring(i, j - i).Replace('-', '.');
                }
            }
            else if (ver.StartsWith("/trunk/mono "))
            {
                rt.monoVersion = "Trunk";
            }

            if (rt.monoVersion == "Unknown")
            {
                i = ver.IndexOf(' ');
                //this schme applies to mono 2.6.3+
                if (ver.Length > i && ver[i + 1] == '(')
                {
                    rt.monoVersion = ver.Substring(0, i);
                }
                //not sure how old this scheme is
                else
                {
                    rt.monoVersion = ver.Substring(i + 1);
                }
            }

            //Pull up assemblies from the installed mono system.
            rt.prefix = PathUp(typeof(int).Assembly.Location, 4);
            if (rt.prefix == null)
            {
                throw new SystemException("Could not detect Mono prefix");
            }

            rt.SetupPkgconfigPaths(Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"),
                                   Environment.GetEnvironmentVariable("PKG_CONFIG_LIBDIR"));

            foreach (string varName in new [] { "PATH", "MONO_GAC_PREFIX", "XBUILD_FRAMEWORK_FOLDERS_PATH" })
            {
                rt.envVars [varName] = Environment.GetEnvironmentVariable(varName);
            }

            rt.IsRunning      = true;
            rt.initialized    = true;
            rt.isValidRuntime = true;

            return(rt);
        }
예제 #9
0
		protected virtual void OnButtonAddClicked (object sender, System.EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select the mono installation prefix")) {
				TransientFor = this.Toplevel as Gtk.Window,
			};
			
			//set a platform-dependent default folder for the dialog if possible
			if (PropertyService.IsWindows) {
				string folder = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86);
				if (!string.IsNullOrEmpty (folder) && System.IO.Directory.Exists (folder))
					dlg.CurrentFolder = folder;
			} else {
				if (System.IO.Directory.Exists ("/usr"))
					dlg.CurrentFolder = "/usr";
			}
			
			if (!dlg.Run ())
				return;
			
			var rinfo = new MonoRuntimeInfo (dlg.SelectedFile);
			if (!rinfo.IsValidRuntime) {
				MessageService.ShowError (GettextCatalog.GetString ("Mono runtime not found"), GettextCatalog.GetString ("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
				return;
			}
			newInfos.Add (rinfo);
			store.AppendValues (rinfo.DisplayName, rinfo);
		}
예제 #10
0
 public static TargetRuntime RegisterRuntime(MonoRuntimeInfo info)
 {
     return(MonoTargetRuntimeFactory.RegisterRuntime(info));
 }
		public static MonoRuntimeInfo FromCurrentRuntime ()
		{
			// Get the current mono version
			Type t = Type.GetType ("Mono.Runtime");
			if (t == null)
				return null;
			
			MonoRuntimeInfo rt = new MonoRuntimeInfo ();
			
			// Since Mono 3.0.5/ee035e3eb463816a9590b09f65842503640c6337 GetDisplayName is public
			string ver = (string) t.InvokeMember ("GetDisplayName", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, null, null, null);
			
			//not sure which version this old scheme applies to
			int i = ver.IndexOf ("/branches/mono-");
			if (i != -1) {
				i += 15;
				int j = ver.IndexOf ('/', i);
				if (j != -1)
					rt.monoVersion = ver.Substring (i, j - i).Replace ('-','.');
			} else if (ver.StartsWith ("/trunk/mono ")) {
				rt.monoVersion = "Trunk";
			}
			
			if (rt.monoVersion == "Unknown") {
				i = ver.IndexOf (' ');
				//this schme applies to mono 2.6.3+
				if (ver.Length > i && ver[i+1] == '(')
					rt.monoVersion = ver.Substring (0, i);
				//not sure how old this scheme is
				else
					rt.monoVersion = ver.Substring (i+1);
			}

			//Pull up assemblies from the installed mono system.
			rt.prefix = PathUp (typeof (int).Assembly.Location, 4);
			if (rt.prefix == null)
				throw new SystemException ("Could not detect Mono prefix");
			
			rt.SetupPkgconfigPaths (Environment.GetEnvironmentVariable ("PKG_CONFIG_PATH"),
			                        Environment.GetEnvironmentVariable ("PKG_CONFIG_LIBDIR"));
			
			foreach (string varName in new [] { "PATH", "MONO_GAC_PREFIX", "XBUILD_FRAMEWORK_FOLDERS_PATH" }) {
				rt.envVars [varName] = Environment.GetEnvironmentVariable (varName);
			}
			
			rt.IsRunning = true;
			rt.initialized = true;
			rt.isValidRuntime = true;
			
			return rt;
		}
예제 #12
0
        public IEnumerable <TargetRuntime> CreateRuntimes()
        {
            MonoRuntimeInfo currentRuntime = MonoRuntimeInfo.FromCurrentRuntime();

            if (currentRuntime != null)
            {
                yield return(new MonoTargetRuntime(currentRuntime));
            }
            if (Platform.IsWindows)
            {
                string progs = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                foreach (string dir in Directory.EnumerateDirectories(progs, "Mono*"))
                {
                    MonoRuntimeInfo info = new MonoRuntimeInfo(dir);
                    if (info.IsValidRuntime)
                    {
                        yield return(new MonoTargetRuntime(info));
                    }
                }
            }
            else if (Platform.IsMac)
            {
                if (!Directory.Exists(MAC_FRAMEWORK_DIR))
                {
                    yield break;
                }
                foreach (string dir in Directory.EnumerateDirectories(MAC_FRAMEWORK_DIR))
                {
                    if (dir.EndsWith("/Current", StringComparison.Ordinal) || currentRuntime.Prefix == dir)
                    {
                        continue;
                    }
                    MonoRuntimeInfo info = new MonoRuntimeInfo(dir);
                    if (info.IsValidRuntime)
                    {
                        yield return(new MonoTargetRuntime(info));
                    }
                }
            }
            else
            {
                foreach (string pref in commonLinuxPrefixes)
                {
                    if (currentRuntime != null && currentRuntime.Prefix == pref)
                    {
                        continue;
                    }
                    MonoRuntimeInfo info = new MonoRuntimeInfo(pref);
                    if (info.IsValidRuntime)
                    {
                        // Clean up old registered runtimes
                        foreach (MonoRuntimeInfo ei in customRuntimes)
                        {
                            if (ei.Prefix == info.Prefix)
                            {
                                customRuntimes.Remove(ei);
                                break;
                            }
                        }
                        yield return(new MonoTargetRuntime(info));
                    }
                }
            }
            foreach (MonoRuntimeInfo info in customRuntimes)
            {
                MonoTargetRuntime rt = new MonoTargetRuntime(info);
                rt.UserDefined = true;
                yield return(rt);
            }
        }
		protected virtual void OnButtonAddClicked (object sender, System.EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select the mono installation prefix")) {
				TransientFor = this.Toplevel as Gtk.Window,
				CurrentFolder = "/usr",
			};
			if (!dlg.Run ())
				return;
			
			var rinfo = new MonoRuntimeInfo (dlg.SelectedFile);
			if (!rinfo.IsValidRuntime) {
				MessageService.ShowError (GettextCatalog.GetString ("Mono runtime not found"), GettextCatalog.GetString ("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
				return;
			}
			newInfos.Add (rinfo);
			store.AppendValues (rinfo.DisplayName, rinfo);
		}
예제 #14
0
		protected virtual void OnButtonAddClicked (object sender, System.EventArgs e)
		{
			var dlg = new SelectFolderDialog (GettextCatalog.GetString ("Select the mono installation prefix")) {
				TransientFor = this.Toplevel as Gtk.Window,
			};

			//set a platform-dependent default folder for the dialog if possible
			if (Platform.IsWindows) {
				// ProgramFilesX86 is broken on 32-bit WinXP
				string programFilesX86 = GetProgramFilesX86 ();
				if (!string.IsNullOrEmpty (programFilesX86) && System.IO.Directory.Exists (programFilesX86))
					dlg.CurrentFolder = programFilesX86;
			} else {
				if (System.IO.Directory.Exists ("/usr"))
					dlg.CurrentFolder = "/usr";
			}

			if (!dlg.Run ())
				return;

			var rinfo64 = new MonoRuntimeInfo (dlg.SelectedFile, true);
			var rinfo32 = new MonoRuntimeInfo (dlg.SelectedFile, false);
			if (rinfo64.IsValidRuntime && rinfo32.IsValidRuntime) {
				newInfos.Add (rinfo64);
				store.AppendValues (rinfo64.DisplayName, rinfo64);
				newInfos.Add (rinfo32);
				store.AppendValues (rinfo32.DisplayName, rinfo32);
			} else if (rinfo64.IsValidRuntime) {
				newInfos.Add (rinfo64);
				store.AppendValues (rinfo64.DisplayName, rinfo64);
			} else if (rinfo32.IsValidRuntime) {
				newInfos.Add (rinfo32);
				store.AppendValues (rinfo32.DisplayName, rinfo32);
			} else {
				var rinfo = new MonoRuntimeInfo (dlg.SelectedFile, null);
				if (rinfo.IsValidRuntime) {
					newInfos.Add (rinfo);
					store.AppendValues (rinfo.DisplayName, rinfo);
				} else {
					MessageService.ShowError (GettextCatalog.GetString ("Mono runtime not found"), GettextCatalog.GetString ("Please provide a valid directory prefix where mono is installed (for example, /usr)"));
				}
			}
		}
		void CreateCommandLineWithSolution (string fileName, MonoRuntimeInfo monoRuntimeInfo)
		{
			CreateCommandLineWithSolution (fileName, monoRuntimeInfo, true);
		}