Follow on from this thread...
http://groups.google.com.ag/group/ccnet-user/browse_thread/thread/8867958676c818e9#

I have this issue which means we can't update. I tried to narrow down
the version where it was introduced by installing versions and
checking whether it happens or not. it is somewhere between 1.4.2.21 -
23 Dec 08 (which works fine) and 1.4.2.3864 (which doesn't work - env
vars are lowercase). I can't narrow it further as there are no builds
in between on ccnetlive.

To test I created a nant project which calls a batch file which just
calls set:
config file:
<cruisecontrol>
        <project name="Test set" queue="settest" queuePriority="1">
                <category>settest</category>
                <triggers/>
                <tasks>
                        <nant>
                                <buildArgs></buildArgs>
                                <buildFile>run.xml</buildFile>
                                <buildTimeoutSeconds>86400</buildTimeoutSeconds>
                                <baseDirectory>C:\Program 
Files\CruiseControl.NET\server\</
baseDirectory>
                                <executable>C:\Program 
Files\nant-0.85\bin\nant.exe</executable>
                                <logger>NAnt.Core.XmlLogger</logger>
                                <nologo>True</nologo>
                                <targetList>
                                        <string>run</string>
                                </targetList>
                        </nant>
                </tasks>
        </project>
</cruisecontrol>

run.xml:
<?xml version="1.0"?>
<project name="test" default="build" basedir="Z:">

        <description>test NAnt Build Script.</description>

        <target name="run" description="">
                <exec program="C:\Program Files\CruiseControl.NET\server\Test 
set
\WorkingDirectory\set.bat" />
        </target>
</project>

set.bat:
set


I am guessing it is to do with the changes the ProcessExecutor but
can't actually see what would cause it. The function we use inside the
tool that gets called uses this function to fix the env, maybe you
could do something similar before calling run on the process (so that
it will work out of the box for every executable):

        private void FixupEnvironmentVariables()
        {
            // 
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=326163

            StringDictionary sd = new StringDictionary();
            foreach (string key in
Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine).Keys)
            {
                sd.Remove(key);
                sd.Add(key, key);
            }

            foreach (string key in
Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User).Keys)
            {
                sd.Remove(key);
                sd.Add(key, key);
            }

            foreach (string key in
Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process).Keys)
            {
                if (sd.ContainsKey(key) && !sd[key].Equals(key,
StringComparison.Ordinal))
                {

                    // We have an env var in the process that is in a
different case at the user or machine level.
                    // Add the correct case version.
                    // Simply resetting the name will have no effect
because Windows will preserve the case in which
                    // it was initially created. We must remove it and
then re-add it.
                    // To remove a environment variable in a process,
you must set the value of it to empty string.
                    string value =
Environment.GetEnvironmentVariable(key,
EnvironmentVariableTarget.Process);
                    Environment.SetEnvironmentVariable(sd[key],
                      "",
                      EnvironmentVariableTarget.Process);

                    // Now set the environment variable using the
correct case.
                    Environment.SetEnvironmentVariable(sd[key],
                      value,
                      EnvironmentVariableTarget.Process);
                }
            }
        }

Thanks in advance,
Arieh

Reply via email to