private static string FindProjectAssemblyIfExists(Project project)
{
if ((project.ConfigurationManager != null)
&& (project.ConfigurationManager.ActiveConfiguration != null)
&& (project.ConfigurationManager.ActiveConfiguration.Properties != null)
&& (project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath") != null)
&& (!string.IsNullOrEmpty((string)project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value))
&& (project.Properties.Item("OutputFileName") != null)
&& (!string.IsNullOrEmpty((string)project.Properties.Item("OutputFileName").Value))
) {
var outputDir = Path.Combine(project.GetFullPath(), (string)project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value);
var assemblyLocation = Path.Combine(outputDir, (string)project.Properties.Item("OutputFileName").Value);
if (File.Exists(assemblyLocation))
return assemblyLocation;
}
return null;
}