I donβt know how to programmatically access "$ (TargetPath)", I agree that this could be a better solution.
However, the approach you mentioned should still be workable, since the OutputPath property refers to the folder in which the project file is located. (Please let me know if I am missing a script where this is not the case?)
So you can do something like this:
private static string GetProjectExecutable(Project startupProject, Configuration config) { string projectFolder = Path.GetDirectoryName(startupProject.FileName); string outputPath = (string)config.Properties.Item("OutputPath").Value; string assemblyFileName = (string)startupProject.Properties.Item("AssemblyName").Value + ".exe"; return Path.Combine(new[] { projectFolder, outputPath, assemblyFileName }); }
(overloading the Path.Combine used here is only available in .NET 4.0, but you can always download it)
Omer raviv
source share