Beispiel #1
0
        public static ProcessStartInfo GetExecutable(this Project project)
        {
            var userProject   = project.FindUserProject();
            var startupAction = userProject?.Xml.GetPropertyValue("StartAction");

            if (!string.IsNullOrEmpty(startupAction))
            {
                var exe  = userProject.Xml.GetPropertyValue("StartProgram");
                var args = userProject.Xml.GetPropertyValue("StartArguments");
                if (File.Exists(exe))
                {
                    return(new ProcessStartInfo(exe, args));
                }
            }

            startupAction = project.GetPropertyValue("StartAction");
            if (!string.IsNullOrEmpty(startupAction))
            {
                var exe  = project.GetPropertyValue("StartProgram");
                var args = project.GetPropertyValue("StartArguments");
                if (File.Exists(exe))
                {
                    return(new ProcessStartInfo(exe, args));
                }
            }

            var startupObject = project.GetPropertyValue("StartupObject");

            if (!string.IsNullOrEmpty(startupObject) && File.Exists(startupObject))
            {
                return(new ProcessStartInfo(startupObject, string.Empty));
            }

            var outputFile = Check.TryCatch <FileInfo, Exception>(() => project.GetOutputFile(".exe"));

            if (outputFile != null && outputFile.Extension == ".exe" && outputFile.Exists)
            {
                return(new ProcessStartInfo(outputFile.FullName, string.Empty));
            }


            //else
            //{
            //    string path = project.GetPropertyValue("OutputPath");
            //    if (!string.IsNullOrEmpty(path))
            //    {

            //    }
            //}
            return(null);
        }