Skip to content

Commit

Permalink
Support environment variable expansion in the RudeBuild cache path, s…
Browse files Browse the repository at this point in the history
…o you can now set it to something like %TEMP%\RudeBuildCache.
  • Loading branch information
martinecker committed May 25, 2016
1 parent cc3f40b commit 6b64e2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/RudeBuild/ProjectInfo.cs
Expand Up @@ -66,6 +66,18 @@ private static int GetPathAttribute(string path)

throw new FileNotFoundException();
}
public static string ExpandEnvironmentVariables(string value)
{
if (string.IsNullOrEmpty(value))
return value;

foreach (DictionaryEntry environmentVariable in Environment.GetEnvironmentVariables())
{
value = value.Replace("%" + (string)environmentVariable.Key + "%", (string)environmentVariable.Value, StringComparison.OrdinalIgnoreCase);
}

return value;
}
}

public class ProjectInfo
Expand Down
2 changes: 1 addition & 1 deletion src/RudeBuild/Settings.cs
Expand Up @@ -64,7 +64,7 @@ public string GetCachePath(SolutionInfo solutionInfo)
string solutionDirectory = solutionInfo.Name + "_" + GetMD5Hash(solutionInfo.FilePath);
string config = BuildOptions.Config.Replace('|', '-');

string cachePath = Path.Combine(GlobalSettings.CachePath, solutionDirectory);
string cachePath = Path.Combine(PathHelpers.ExpandEnvironmentVariables(GlobalSettings.CachePath), solutionDirectory);
cachePath = Path.Combine(cachePath, config);
return cachePath;
}
Expand Down

0 comments on commit 6b64e2e

Please sign in to comment.