in SmvInterceptor/SmvInterceptor.cs [438:488]
private static void ModifyEnvironment(XmlNode launchNode, bool stripPath)
{
// Remove the tool from the path
if (stripPath)
{
// Canonize the intercept dir
string canonizedInterceptDir = CanonizePath(interceptDir);
// StringBuilder for the new path to be rebuilt from pieces
StringBuilder newPath = new StringBuilder();
string[] pathPieces = Environment.GetEnvironmentVariable("PATH").Split(';');
// Loop through each piece
foreach (string piece in pathPieces)
{
// Skip empty pieces
if (piece.Length < 1)
continue;
// Canonize this piece. NOTE: This will convert a relative path into a full path, which could cause wonkiness
string canonPiece = Path.GetFullPath(CanonizePath(piece)).ToLowerInvariant();
if (canonPiece != null && canonPiece.Length > 0 && canonPiece != canonizedInterceptDir)
{
if (newPath.Length > 0)
newPath.Append(";");
newPath.Append(piece);
}
}
// Set final PATH into environment
Environment.SetEnvironmentVariable("PATH", newPath.ToString());
if (debugSpew)
Console.WriteLine("PATH = {0}", Environment.GetEnvironmentVariable("PATH"));
}
// Process any extra environment variables in the launchNode
if (launchNode != null)
{
foreach (XmlNode node in launchNode.SelectNodes("ENV"))
{
foreach (XmlAttribute attrib in node.Attributes)
{
string name = attrib.Name, value = attrib.Value;
value = Environment.ExpandEnvironmentVariables(value);
Environment.SetEnvironmentVariable(name, value);
}
}
}
}