Menu

#744 <sysinfo /> on x64 systems

0.91-alpha1
open
nobody
Tasks (408)
5
2010-07-21
2010-07-21
Bogdan P
No

On my W7x64 task <sysinfo /> does not work. Looking with reflector the error comes from:

public class PropertyDictionary : DictionaryBase
- private static void ValidatePropertyName(string propertyName, Location location)

Output by Nant is:

Property name 'sys.env.CommonProgramFiles(x86)' is invalid.:
NAnt.Core.BuildException: Property name 'sys.env.CommonProgramFiles(x86)' is inv
alid.
at NAnt.Core.PropertyDictionary.ValidatePropertyName(String propertyName, Loc
ation location)
at NAnt.Core.PropertyDictionary.OnValidate(Object key, Object value)
at System.Collections.DictionaryBase.System.Collections.IDictionary.set_Item(
Object key, Object value)
at NAnt.Core.PropertyDictionary.set_Item(String name, String value)
at NAnt.Core.Tasks.SysInfoTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.Project.InitializeProjectDocument(XmlDocument doc)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()

This show that this line of code from method above raises an error:

if (!Regex.IsMatch(propertyName, @"^[_A-Za-z0-9][_A-Za-z0-9\-.]*$"))
{
throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1064"), new object[] { propertyName }), location);
}

Solution:

Allow ( and ) in property name.

Discussion

  • Dominik Guder

    Dominik Guder - 2010-07-31

    Hi,
    I stubled about this issue some other day before releasing 0.90.
    The reason is the function parser which needs the parens as separator to work correctly. Therefore they are excluded from property names.
    I did some checkings like renaming ( and ) to _. But finally we did not came to an acceptable solution what to do now and posponed the issue.

    Until we grab this issue again, the only way is to set failonerror="false" on sysinfo task.

    So far Dominik

     
  • Ryan Boggs

    Ryan Boggs - 2010-08-13

    Ugg, this error. This one is complicated because of this task uses the same check system that is used to validate variable names, if I remember correctly. At the time we found it, it was decided that the work around that Dominik described would be sufficient. However, as more systems go the x64 route, I can see this needing more attention.

     
  • Great123

    Great123 - 2012-03-21

    Hi,

    I am facing the same issue(Property name 'sys.env.CommonProgramFiles(x86)' is invalid) while using nant-0.91-alpha2.

    Please can you help me in which location of the code of the sysinfo.cs i need to add the failonerror="false".

    protected override void ExecuteTask()
    {
    Log(Level.Info, "Setting system information properties under " + Prefix + "*");

    // set properties
    Properties[Prefix + "clr.version"] = Environment.Version.ToString();
    Properties[Prefix + "os.platform"] = Environment.OSVersion.Platform.ToString(CultureInfo.InvariantCulture);
    Properties[Prefix + "os.version"] = Environment.OSVersion.Version.ToString();
    Properties[Prefix + "os.folder.applicationdata"] = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    Properties[Prefix + "os.folder.commonapplicationData"] = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
    Properties[Prefix + "os.folder.commonprogramFiles"] = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles);
    Properties[Prefix + "os.folder.desktopdirectory"] = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
    Properties[Prefix + "os.folder.programfiles"] = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
    Properties[Prefix + "os.folder.system"] = Environment.GetFolderPath(Environment.SpecialFolder.System);
    Properties[Prefix + "os.folder.temp"] = Path.GetTempPath();
    Properties[Prefix + "os"] = Environment.OSVersion.ToString();

    // set environment variables
    IDictionary variables = Environment.GetEnvironmentVariables();
    foreach (string name in variables.Keys)
    {
    try
    {
    Properties[Prefix + "env." + name] = (string)variables[name];
    }
    catch (Exception ex)
    {
    if (!FailOnError)
    {
    Log(Level.Warning, "Property could not be created for"
    + " environment variable '{0}' : {1}", name,
    ex.Message);
    }
    else
    {
    throw;
    }

    }
    }

    // display the properties
    if (Verbose)
    {
    foreach (DictionaryEntry entry in Properties)
    {
    string name = (string)entry.Key;
    if (name.StartsWith(Prefix))
    {
    Log(Level.Info, name + " = " + entry.Value.ToString());
    }
    }
    }
    }

    #endregion Override implementation of Task
    }

     

Log in to post a comment.