Ok, i got a workaround.
I made another little tool that takes two arguments. First one is the project directory, the second is the project file (*.csproj, *.vbproj, etc.).
The project file is saved as an XML file which makes it very easy to read programatically. So i simply read the path information from there.
I tested this on a couple of my projects including the one i saved on my desktop. So far it worked, but im pretty sure you could somehow get it to fail.
anyways, heres the code. Take a look and use it if you want:
static void Main(string[] args)
{
// Check if arguments has been passed
if (args.Length == 2)
{
// Save the 2 arguments
string path = args[0];
string file = args[1];
// Check if the project file exists
if (File.Exists(path + file))
{
// Go to the projects directory
Directory.SetCurrentDirectory(path);
// Read the XML project file into a dataset
// Get the proper table into a datatable
DataSet ds = new DataSet();
ds.ReadXml(file);
DataTable dt = ds.Tables["PropertyGroup"];
// Get the information from the table that is needed
string exeName = (string)dt.Rows[0]["AssemblyName"] + ".exe";
// use dt.Rows[2]["OutputPath"] for release path
string relativePath = (string)dt.Rows[1]["OutputPath"];
// Luckily, the File and Directory classes supports relative paths
if (File.Exists(relativePath + "\" + exeName))
{
Directory.SetCurrentDirectory(relativePath);
string theFile = string.Format(@"{0}{1}", Directory.GetCurrentDirectory(), exeName);
MessageBox.Show("The file your looking for is:n" + theFile);
}
}
}
}
This goes into the parameters box in the custom tools menu of Visual Studio (note the space):
$(ProjectDir) $(ProjectFileName)
Using Dark GDK.NET