Kaynağa Gözat

Support for publishing UICatalog as single file (#3074)

Thomas Nind 1 yıl önce
ebeveyn
işleme
e885af0282
2 değiştirilmiş dosya ile 22 ekleme ve 4 silme
  1. 9 1
      UICatalog/Scenarios/Animation.cs
  2. 13 3
      UICatalog/UICatalog.cs

+ 9 - 1
UICatalog/Scenarios/Animation.cs

@@ -39,7 +39,15 @@ namespace UICatalog.Scenarios {
 			};
 			Win.Add (lbl2);
 
-			var dir = new DirectoryInfo (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location));
+			DirectoryInfo dir;
+
+			var assemblyLocation = Assembly.GetExecutingAssembly ().Location;
+
+			if (!string.IsNullOrEmpty (assemblyLocation)) {
+				dir = new DirectoryInfo (Path.GetDirectoryName (assemblyLocation));
+			} else {
+				dir = new DirectoryInfo (System.AppContext.BaseDirectory);
+			}
 
 			var f = new FileInfo (
 				Path.Combine (dir.FullName, "Scenarios", "Spinning_globe_dark_small.gif"));

+ 13 - 3
UICatalog/UICatalog.cs

@@ -147,8 +147,18 @@ class UICatalogApp {
 	{
 		// Setup a file system watcher for `./.tui/`
 		_currentDirWatcher.NotifyFilter = NotifyFilters.LastWrite;
-		var f = new FileInfo (Assembly.GetExecutingAssembly ().Location);
-		string tuiDir = Path.Combine (f.Directory!.FullName, ".tui");
+
+		var assemblyLocation = Assembly.GetExecutingAssembly ().Location;
+		string tuiDir;
+
+		if (!string.IsNullOrEmpty (assemblyLocation)) {
+			var assemblyFile = new FileInfo (assemblyLocation);
+			tuiDir = Path.Combine (assemblyFile.Directory!.FullName, ".tui");
+		} else {
+			tuiDir = Path.Combine (System.AppContext.BaseDirectory, ".tui");
+		}
+
+
 
 		if (!Directory.Exists (tuiDir)) {
 			Directory.CreateDirectory (tuiDir);
@@ -158,7 +168,7 @@ class UICatalogApp {
 
 		// Setup a file system watcher for `~/.tui/`
 		_homeDirWatcher.NotifyFilter = NotifyFilters.LastWrite;
-		f = new FileInfo (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile));
+		var f = new FileInfo (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile));
 		tuiDir = Path.Combine (f.FullName, ".tui");
 
 		if (!Directory.Exists (tuiDir)) {