I would like the following assistance with a post-build command event in a C#.net 2008 desktop application:
1. If a post-build command event does not work, can you tell me where I would see any error messages?
2. How would you debug a post-build command event just like the way it is suppose to run? Do you use some command line prompt? The only thing I can think of is to set the project file listed in the post-build command event to the startup project, rebuild and step through the code. However when I attempt to step through the code in 'debug' mode, the application does get get the 'debug' parameter.
3. I believe the post-build command event should run since it is set to run on successful build. When I build the project file that has the following command C:\Tracbuild.exe Debug , the entire solution rebuilds successfully with a few warnings.
4. I think the Tracbuild project did not execute since I do not see the output where the Tracbuild is suppose to place output files. Do you think I may need to look at some security settting? Maybe an output folder should be created. The following is most of the code in the Tracbuild project. Could you suggest what else I could be looking for?
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using EnrollTrac.Common;
namespace TracBuild
{
class Program
{
static int Main(string[] args)
{
try
{
Console.WriteLine("Current Directory: " + Directory.GetCurrentDirectory());
try
{
Directory.Delete(Directory.GetCurrentDirectory() + "\\output", true);
}
catch (Exception ex)
{
Console.WriteLine("Warning while attempting delete on 'output' directory. " + ex.Message);
}
string ConfigurationName = args[0];
File.Copy("App." + ConfigurationName + ".Config", "app.Exe.Config", true);
//copy executables
File.Copy("app.exe", "app2.Exe", true);
foreach (string configfile in Directory.GetFiles(Directory.GetCurrentDirectory(), "App.*.Config"))
{
File.Delete(configfile);
}
Console.WriteLine("Executing TracBuild for " + ConfigurationName);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
Console.Error.WriteLine(ex.StackTrace);
return 1;
}
return 0;
}
}
Loading
Sam HobbsPosted Jul 31, 2011, 6:47 PM
Also, note a project is something that is built and it prduces an executable program. Programs are executed. Beginners often talk about executing projects, but that can cause confusion. To be more specific, I am not sure what you mean by "Tracbuild project did not execute".
The TracBuild program is using GetCurrentDirectory. This might not be a problem but it seems to be one thing that would slightly complicate testing. If it were me, I would somehow pass the directory as a parameter. Testing the program would as challenging and as easy as testing other application programs. Just analyze the program and determine what it does then set up a test environment. You might need to write another program or a script to do things such as create directories and/or files. You are a developer; this is what you should know how to do. If you are not sure of the details, then please create a thread with more specific questions such as that. You can determine if the program executes by doing one of many things; you could write debug messages to a file that is just for diagnostic purposes and the file has a hard-coded path. Or you could use a MessageBox. Or you could do something else; a good developer can solve the problem easily enough.
Is the post-build configured to redirect standard output? It has been a while since I have set up a post-build but there is a way somehow to configre the post-build to redirect standard output. So in other words, your Console.WriteLine and/or your Console.Error.WriteLine messages could go to the build log. If the post-build is configured in that manner and you are not getting the messages, then you have justification for suspecting that the post-build is not executing the program you need it to.