Just to share what I've done with it...

In Debug Mode:

Options->Custom Commands
 * Before Build
        Command: /bin/date -j "+%m/%d/%Y %H:%M:%S" >builddate.txt
        Working Directory: ${ProjectDir}
        Run on external console: checked

Perform a debug build so that builddate.txt is generated.

Add builddate.txt to the project. 
        Build Action: Content

In AppDeleage.cs

add the following member variables.

        static public DateTime BUILD_DATE { get; set; }
        static public string BUILD_NAME { get; set; }
        static public string BUILD_FLAVOR { get; set; }
        static public string BUILD_VERSION { get; set; }
        static public string BUILD_VERSION_SIMPLE { get; set; }
        static public string BUILD_VERSION_LONG { get; set; }
        static public int BUILD_NUMBER { get; set; }

In FinishedLaunching, at the beginning of the method add:

        BUILD_NAME = 
NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleDisplayName").ToString();
        string vs = 
NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString();
        string v = 
NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString();
        BUILD_NUMBER = Convert.ToInt32(v);
        BUILD_VERSION = string.Format("{0} ({1})", vs, v);
#if ADHOC
        BUILD_FLAVOR = "ADHOC";
#elif APPSTORE
        BUILD_FLAVOR = "APPSTORE";
#else
        BUILD_FLAVOR = "DEV";
#endif
        BUILD_VERSION_SIMPLE = string.Format("{0} {1} ({2}) {3}", BUILD_NAME, 
vs, v, BUILD_FLAVOR);
        DateTime date;
        string dateString = File.ReadAllText("builddate.txt");
        if (DateTime.TryParse(dateString, out date))
                BUILD_DATE = date;
        BUILD_VERSION_LONG = string.Format("{0} {1} ({2}) {3} {4}", BUILD_NAME, 
vs, v, BUILD_FLAVOR, BUILD_DATE);



On Jul 24, 2012, at 2:54 AM, David Junod wrote:

> yes.
> 
> It works when I do the "Run on external console", but that causes a console 
> window to appear that I have to close for the build to continue.
> 
> I'll mess with it more later... it does work, just annoying :-)
> 
> Thanks again, forgot about doing that, have done this same thing before 
> previous projects.
> 
> On Jul 23, 2012, at 9:16 PM, Jason Awbrey wrote:
> 
>> are you using 
>> 
>> Working Directory ==> ${ProjectDir}
>> 
>> and "Run on external console" checked
>> 
>> (sorry I didn't get more specific about those earlier)
>> 
>> On Mon, Jul 23, 2012 at 10:18 PM, David Junod 
>> <[email protected]> wrote:
>> dumb question perhaps, but how do you get it so that it doesn't give a build 
>> error?  I did exactly as you stated and /bin/date returns 1 (causing an 
>> error).
>> 
>> On Jul 23, 2012, at 10:02 AM, Jason Awbrey wrote:
>> 
>>> I have a custom build command like this
>>> 
>>> /bin/date > builddate.txt
>>> 
>>> and then in a tableview cell in my "About" section I have this
>>> 
>>> cell.DetailTextLabel.Text = System.IO.File.ReadAllText("builddate.txt");
>>> 
>>> as well as the version data
>>> 
>>>                     cell.TextLabel.Text = "Version";
>>>                     cell.DetailTextLabel.Text = 
>>> NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString();
>>> 
>>> On Mon, Jul 23, 2012 at 11:55 AM, David Junod 
>>> <[email protected]> wrote:
>>> That would be helpful.
>>> 
>>> Thanks
>>> 
>>> 
>>> On Jul 23, 2012, at 9:51 AM, Jason Awbrey wrote:
>>> 
>>>> I've done this before with a post-build action.  If you're interested I 
>>>> can lookup the code I used to do it
>>>> 
>>>> On Mon, Jul 23, 2012 at 11:50 AM, David Junod 
>>>> <[email protected]> wrote:
>>>> Is there any way with MonoDevelop that I can have a constant for when my 
>>>> app was built (that I don't have to maintain manually).
>>>> 
>>>>         Console.WriteLine("Build: {0} {1}", versionString, BUILD_DATE);
>>>> _______________________________________________
>>>> MonoTouch mailing list
>>>> [email protected]
>>>> http://lists.ximian.com/mailman/listinfo/monotouch
>>>> 
>>> 
>>> 
>> 
>> 
> 
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch

_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to