Skip to content

Commit 3c50d51

Browse files
committed
Merge pull request #980 from wise0704/BuildEventVars
BuildEventVars
2 parents cff27d8 + 9bf0fa4 commit 3c50d51

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

External/Plugins/ProjectManager/Projects/BuildEventVars.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public BuildEventInfo(string name, string value)
1818
}
1919

2020
// SendKeys requires brackets around certain characters which have meaning
21-
public string SendKeysName { get { return "${(}"+Name+"{)}"; } }
22-
public string FormattedName { get { return "$("+Name+")"; } }
21+
public string SendKeysName { get { return "${(}" + Name + "{)}"; } }
22+
public string FormattedName { get { return "$(" + Name + ")"; } }
2323
}
2424

2525
public class BuildEventVars
@@ -70,36 +70,43 @@ public string BaseDir
7070
{
7171
get
7272
{
73-
Uri uri = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
74-
// special behavior if we're running in flashdevelop.exe
75-
if (Path.GetFileName(uri.LocalPath).ToLower() == DistroConfig.DISTRIBUTION_NAME.ToLower() + ".exe")
73+
string localPath = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase).LocalPath;
74+
string entry = Path.GetFileName(localPath);
75+
string flashdevelop = DistroConfig.DISTRIBUTION_NAME + ".exe";
76+
77+
string appDir = Path.GetDirectoryName(localPath);
78+
if (!entry.Equals(flashdevelop, StringComparison.OrdinalIgnoreCase))
7679
{
77-
string local = Path.Combine(Path.GetDirectoryName(uri.LocalPath), ".local");
78-
if (!File.Exists(local))
79-
{
80-
String appDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
81-
return Path.Combine(appDir, DistroConfig.DISTRIBUTION_NAME);
82-
}
83-
else return Path.GetDirectoryName(uri.LocalPath);
80+
// assume we're running in fdbuild.exe - appDir is fdbuildDir
81+
string toolsDir = Path.GetDirectoryName(appDir);
82+
appDir = Path.GetDirectoryName(toolsDir);
8483
}
85-
else return string.Empty;
84+
85+
string local = Path.Combine(appDir, ".local");
86+
if (File.Exists(local)) return appDir;
87+
88+
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
89+
return Path.Combine(localAppData, DistroConfig.DISTRIBUTION_NAME);
8690
}
8791
}
8892

8993
public string FDBuild
9094
{
9195
get
9296
{
93-
Uri uri = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
97+
string localPath = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase).LocalPath;
98+
string entry = Path.GetFileName(localPath);
99+
string flashdevelop = DistroConfig.DISTRIBUTION_NAME + ".exe";
100+
94101
// special behavior if we're running in flashdevelop.exe
95-
if (Path.GetFileName(uri.LocalPath).ToLower() == DistroConfig.DISTRIBUTION_NAME.ToLower() + ".exe")
102+
if (entry.Equals(flashdevelop, StringComparison.OrdinalIgnoreCase))
96103
{
97-
string startupDir = Path.GetDirectoryName(uri.LocalPath);
98-
string toolsDir = Path.Combine(startupDir, "Tools");
104+
string appDir = Path.GetDirectoryName(localPath);
105+
string toolsDir = Path.Combine(appDir, "Tools");
99106
string fdbuildDir = Path.Combine(toolsDir, "fdbuild");
100107
return Path.Combine(fdbuildDir, "fdbuild.exe");
101108
}
102-
else return uri.LocalPath;
109+
else return localPath;
103110
}
104111
}
105112

0 commit comments

Comments
 (0)