Thanks for the input Phil. I was using an older version of CCNet and
wasn't aware of dynamic parameters. They are exactly what I was
looking for! I have run into a problem though. I am having trouble
using dynamic parameters to prompt the user for logon details to SVN.
My code is as follows:
<project name="Test Project">
<webURL>xxx</webURL>
<sourcecontrol type="svn">
<trunkUrl>xxx</trunkUrl>
<workingDirectory>xxx</workingDirectory>
<username>$[SVNUsername]</username>
<password>$[SVNPassword]</password>
<executable>C:\Program Files\VisualSVN\bin\svn.exe</executable>
</sourcecontrol>
...
<parameters>
<textParameter name="SVNUsername">
<description>SVN Username</description>
<minimum>4</minimum>
<maximum>20</maximum>
<required>true</required>
</textParameter>
<textParameter name="SVNPassword">
<description>SVN Password</description>
<minimum>4</minimum>
<maximum>20</maximum>
<required>true</required>
</textParameter>
</parameters>
</project>
However, I get the following error when I try to run a force build:
[Test Project:ERROR] INTERNAL ERROR: Invalid cast from 'System.String'
to 'ThoughtWorks.CruiseControl.Core.Util.PrivateString'.
----------
System.InvalidCastException: Invalid cast from 'System.String' to
'ThoughtWorks.CruiseControl.Core.Util.PrivateString'.
at System.Convert.DefaultToType(IConvertible value, Type
targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type,
IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at
ThoughtWorks.CruiseControl.Core.Tasks.DynamicValueUtility.PropertyValue.ChangeFieldValue(Object
value)
at
ThoughtWorks.CruiseControl.Core.Tasks.DynamicValueUtility.PropertyValue.ChangeProperty(Object
value)
at
ThoughtWorks.CruiseControl.Core.Tasks.DirectDynamicValue.ApplyTo(Object
value, Dictionary`2 parameters, IEnumerable`1 parameterDefinitions)
at
ThoughtWorks.CruiseControl.Core.Sourcecontrol.SourceControlBase.ApplyParameters(Dictionary`2
parameters, IEnumerable`1 parameterDefinitions)
at
ThoughtWorks.CruiseControl.Core.Project.Integrate(IntegrationRequest
request)
----------
[Test Project:ERROR] INTERNAL ERROR: Invalid cast from 'System.String'
to 'ThoughtWorks.CruiseControl.Core.Util.PrivateString'.
----------
System.InvalidCastException: Invalid cast from 'System.String' to
'ThoughtWorks.CruiseControl.Core.Util.PrivateString'.
at System.Convert.DefaultToType(IConvertible value, Type
targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type,
IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at
ThoughtWorks.CruiseControl.Core.Tasks.DynamicValueUtility.PropertyValue.ChangeFieldValue(Object
value)
at
ThoughtWorks.CruiseControl.Core.Tasks.DynamicValueUtility.PropertyValue.ChangeProperty(Object
value)
at
ThoughtWorks.CruiseControl.Core.Tasks.DirectDynamicValue.ApplyTo(Object
value, Dictionary`2 parameters, IEnumerable`1 parameterDefinitions)
at
ThoughtWorks.CruiseControl.Core.Sourcecontrol.SourceControlBase.ApplyParameters(Dictionary`2
parameters, IEnumerable`1 parameterDefinitions)
at
ThoughtWorks.CruiseControl.Core.Project.Integrate(IntegrationRequest
request)
at ThoughtWorks.CruiseControl.Core.ProjectIntegrator.Integrate()
at ThoughtWorks.CruiseControl.Core.ProjectIntegrator.Run()
----------
Can anyone help me with fixing this?
On Apr 23, 12:37 am, "Phil Sayers" <[email protected]> wrote:
> Dynamic Parameters are your
> friend.http://confluence.public.thoughtworks.org/display/CCNET/Dynamic+Param...
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
>
> Behalf Of Mike M
> Sent: Wednesday, April 21, 2010 11:49 PM
> To: ccnet-user
> Subject: [ccnet-user] CCNet + NAnt + C#
>
> Hi guys,
> I have a C# script within my NAnt build file which allows me to accept
> user input from the commandline. A truncutated excerpt of the NAnt
> build file is:
> ...
> <property name="username" value="" />
> <property name="password" value="" />
> <property name="database" value="" />
> ...
> <target name="menu">
> <script language="C#" mainclass="GetInput">
> <code>
> <![CDATA[
> class GetInput
> {
> public static void ScriptMain(Project project)
> {
> Console.Clear();
>
> Console.WriteLine("=========================================================
> ==========");
> Console.WriteLine("Welcome to the Compile and Deploy
> Oracle Forms and Reports Facility");
>
> Console.WriteLine("=========================================================
> ==========");
> Console.Write("Please enter username: ");
> project.Properties["username"] = Console.ReadLine();
> Console.WriteLine();
> Console.Write("Please enter password: ");
> project.Properties["password"] = Console.ReadLine();
> Console.WriteLine();
> Console.Write("Please enter database: ");
> project.Properties["database"] = Console.ReadLine();
> Console.WriteLine();
> ...
> ]]>
> </code>
> </script>
> </target>
>
> When I run this build file from the commandline, it works perfectly.
> However, when I call this build file from CCNet it does not work. The
> only reason for this I can think of is that when CCNet calls the NAnt
> script, it is not sure how to pass the C# script calls to the
> System.Console class to the commandline. I'm not sure how to do this
> though.
>
> I've also been playing around with the idea of the C# script opening a
> new instance of cmd.exe and then trying to execute the remainder of
> the script. From searches on Google, I found the following solution
> that works as a C# class:
>
> using System;
> using System.Windows.Forms;
> using System.Text;
> using System.IO;
> using System.Runtime.InteropServices;
> using Microsoft.Win32.SafeHandles;
> class Program
> {
> [DllImport("kernel32.dll",
> EntryPoint = "GetStdHandle",
> SetLastError = true,
> CharSet = CharSet.Auto,
> CallingConvention = CallingConvention.StdCall)]
> private static extern IntPtr GetStdHandle(int nStdHandle);
> [DllImport("kernel32.dll",
> EntryPoint = "AllocConsole",
> SetLastError = true,
> CharSet = CharSet.Auto,
> CallingConvention = CallingConvention.StdCall)]
> private static extern int AllocConsole();
> private const int STD_OUTPUT_HANDLE = -11;
> private const int MY_CODE_PAGE = 437;
> private static string deployment = "\\\\vm-osb-oasd\\sohaan";
> static void Main(string[] args)
> {
> AllocConsole();
> IntPtr stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
> SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle,
> true);
> FileStream fileStream = new FileStream(safeFileHandle,
> FileAccess.Write);
> Encoding encoding =
> System.Text.Encoding.GetEncoding(MY_CODE_PAGE);
> StreamWriter standardOutput = new StreamWriter(fileStream,
> encoding);
> standardOutput.AutoFlush = true;
> Console.SetOut(standardOutput);
> Console.Clear();
>
> Console.WriteLine("=========================================================
> ==========");
> Console.WriteLine("Welcome to the Compile and Deploy Oracle
> Forms and Reports Facility");
>
> Console.WriteLine("=========================================================
> ==========");
> Console.Write("Please enter username: ");
> string username = Console.ReadLine();
> ....
> }
> }
> This works perfectly in a C# environment. However, I do not know how
> to embed it within a NAnt script correctly...From what I know about
> NAnt, I may need to create an extension, but am uncertain of how to go
> about this. Can anyone help me out?
>
> --
> Subscription
> settings:http://groups.google.com/group/ccnet-user/subscribe?hl=en- Hide
> quoted text -
>
> - Show quoted text -