Exemple #1
0
        /// <summary>
        /// pushes the nuPkg file to the given url
        /// </summary>
        /// <returns>true if the push was successfull, false otherwise</returns>
        private void PushNuGetPackage(string url, string apiKey, string nuPkgFilePath)
        {
            LoggingManager.Instance.Logger.Debug("pushing nupkg file");

            //-----push the nuPkg file to the server
            string result;
            string error;
            string command = string.Format(@" ""{0}"" push ""{1}"" -source ""{2}"" ""{3}"" ",
                                           OptionsManager.Instance.Configuration.GeneralOptions.NuGetOptions.ExePath,
                                           nuPkgFilePath,
                                           url,
                                           apiKey);

            LoggingManager.Instance.Logger.Debug(string.Format("Executing command [{0}]", command));
            CommandUtil.ExecuteCommand(command, new string[] { "/C" }, out result, out error);

            //-----show a message about success or error
            if (!string.IsNullOrEmpty(error))
            {
                throw new PublishNuGetPackageFailedExceptions(string.Format("An Error occured while deploying the nuPkg file: {0}", error));
            }

            //-----delete the nuPkg file is possible
            try
            {
                File.Delete(nuPkgFilePath);
            }
            catch (Exception ex)
            {
                LoggingManager.Instance.Logger.Warn(ex);
            }
            LoggingManager.Instance.Logger.Debug("pushing nupkg file finished");
        }
 /// <summary>
 /// prepares the nuGet exe path if it has not been set yet
 /// </summary>
 /// <returns>true if the nuGet exe path needed to be set, false otherwise</returns>
 private bool PrepareNuGetExePath()
 {
     //-----try to get the nuGet exe path from command line as long as its not set
     if (string.IsNullOrEmpty(_configuration.GeneralOptions.NuGetOptions.ExePath))
     {
         string result = null;
         string error  = null;
         try
         {
             CommandUtil.ExecuteCommand("where nuget", new string[] { "/C" }, out result, out error);
             if (result != null && result.EndsWith("\r\n"))
             {
                 result = result.Replace("\r\n", "");
             }
         }
         catch (Exception ex) { LoggingManager.Instance.Logger.Error(ex); }
         //-----set path and save settings if found
         if (!string.IsNullOrEmpty(result))
         {
             _configuration.GeneralOptions.NuGetOptions.ExePath = result;
             return(true);
         }
     }
     return(false);
 }
        public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
        {
            if (buildTarget != BuildTarget.Android)
            {
                return;
            }

            // open project dir
            CommandUtil.ExecuteCommand("explorer " + path);
        }
Exemple #4
0
        private static bool ExecutedPod(string podPath, string projectPath)
        {
            string commandLine = string.Format("cd {0} && {1} repo update && {2} update && {3} install",
                                               projectPath, podPath, podPath, podPath);

            Log.I(TAG, "start executed command\n{0}", commandLine);
            CommandUtil.CommandResult result = CommandUtil.ExecuteCommand(commandLine);

            if (result.resultCode == 0)
            {
                return(true);
            }

            Log.E(TAG, "executed command error!\n{0}\n{1}", result.output, result.error);

            return(false);
        }
Exemple #5
0
 public static void OnPostprocessBuild2(BuildTarget buildTarget, string path)
 {
     // open project file
     CommandUtil.ExecuteCommand("open " + path);
 }
Exemple #6
0
        /// <summary>
        /// build the project using the given msbuild exe
        /// </summary>
        /// <param name="msBuildPath">full path to the msbuild exe to use</param>
        /// <returns>true if the build process was successful, false otherwise</returns>
        private void BuildProject(DeploymentInformation deployInfo)
        {
            LoggingManager.Instance.Logger.Debug("building project");

            //-----start the build process of the project
            string result;
            string error;

            if (!Directory.Exists(deployInfo.Build.BuildPath))
            {
                LoggingManager.Instance.Logger.Debug(string.Format("creating directory {0}", deployInfo.Build.BuildPath));
                Directory.CreateDirectory(deployInfo.Build.BuildPath);
            }

            string buildFileFullname = Path.Combine(deployInfo.Build.BuildPath, deployInfo.OutputFileName);

            StringBuilder command = new StringBuilder(string.Format(@"{0} ""{1}"" ", deployInfo.MsBuildFullName, deployInfo.ProjectFullName));

            command.Append(string.Format(@" /p:Configuration=""{0}"" ", deployInfo.Build.ConfigurationName));

            command.Append(string.Format(@" /p:Platform=""{0}"" ", deployInfo.Build.PlatformName));

            command.Append(string.Format(@" /p:OutputPath=""{0}"" ", deployInfo.Build.BuildPath));

            if (deployInfo.ProjectOptions.MsBuildOptions.Usage.Optimize.Useage != Enumerations.Useage.None && deployInfo.Build.Optimize != null)
            {
                command.Append(string.Format(@" /p:Optimize={0} ", deployInfo.Build.Optimize.ToString()));
            }

            if (deployInfo.ProjectOptions.MsBuildOptions.Usage.DebugConstants.Useage != Enumerations.Useage.None && !string.IsNullOrEmpty(deployInfo.Build.DebugConstants))
            {
                command.Append(string.Format(@" /p:DefineConstants=""{0}"" ", deployInfo.Build.DebugConstants));
            }

            if (deployInfo.ProjectOptions.MsBuildOptions.Usage.DebugInfo.Useage != Enumerations.Useage.None && !string.IsNullOrEmpty(deployInfo.Build.DebugInfo))
            {
                command.Append(string.Format(@" /p:DebugSymbols=true /p:DebugType={0} ", deployInfo.Build.DebugInfo.ToString()));
            }

            if (deployInfo.Build.DocumentationFile != null)
            {
                command.Append(string.Format(@" /p:DocumentationFile=""{0}"" ", deployInfo.Build.DocumentationFile.Source));
            }

            LoggingManager.Instance.Logger.Debug(string.Format("executing command [{0}]", command.ToString()));
            CommandUtil.ExecuteCommand(command.ToString(), new string[] { "/C" }, out result, out error);

            //-----make sure the build process was successfull
            if (!string.IsNullOrEmpty(error) || !File.Exists(buildFileFullname))
            {
                //HACK should be reworked since it is not very save, but currently the only way
                if (string.IsNullOrEmpty(error) && deployInfo.ProjectOptions.Identifier == Enumerations.ProjectIdentifier.CPP)
                {
                    Xml.NuGet.NuSpec.File fileDll = deployInfo.NuSpecPackage.Files.FirstOrDefault(f => f.Source == buildFileFullname);
                    Xml.NuGet.NuSpec.File filePdb = deployInfo.NuSpecPackage.Files.FirstOrDefault(f => f.Source == StringUtil.ReplaceLastOccurrence(buildFileFullname, Resources.ExtensionDLL, Resources.ExtensionPDB));

                    if (fileDll != null)
                    {
                        deployInfo.Build.BuildPath = Path.Combine(Path.GetDirectoryName(deployInfo.ProjectFullName), deployInfo.Build.PlatformName, deployInfo.Build.ConfigurationName);

                        buildFileFullname = Path.Combine(deployInfo.Build.BuildPath, deployInfo.OutputFileName);

                        LoggingManager.Instance.Logger.Warn(string.Format("could not create the orignal file for cpp project, checking if file {0} exists", buildFileFullname));

                        if (File.Exists(buildFileFullname))
                        {
                            fileDll.Source = buildFileFullname;

                            if (filePdb != null)
                            {
                                filePdb.Source = StringUtil.ReplaceLastOccurrence(buildFileFullname, Resources.ExtensionDLL, Resources.ExtensionPDB);
                            }

                            XmlUtil.Serialize(deployInfo.NuSpecFileFullName, deployInfo.NuSpecPackage);

                            return;
                        }
                    }
                }
                throw new ProjectBuildFailedExceptions(!string.IsNullOrEmpty(error) ? string.Format("An Error occured during the build process: {0}", error) :
                                                       string.Format("Could not create file: {0}", buildFileFullname));
            }
            LoggingManager.Instance.Logger.Debug("building project finished");
        }
        /// <summary>
        /// prepares them ms build path if non exists yet
        /// </summary>
        /// <returns>true if at least one ms build path was found and used, false otherwise</returns>
        private bool PrepareMsBuildPath()
        {
            bool needsSave = false;

            //-----try to get all known ms build paths
            if (Configuration.GeneralOptions.MsBuildOptions.ExePaths.Count == 0)
            {
                //-----ms build variables
                string   path       = "Microsoft.NET\\Framework";
                string   executable = "msbuild.exe";
                string[] versions   = new string[] { "v4.0", "v3.5", "v3.0", "v2.0", "v1.1", "v1.0" };

                string result = null;
                string error  = null;
                try
                {
                    //-----check if msbuild was set to the command line
                    string commandPath = null;
                    CommandUtil.ExecuteCommand("where msbuild", new string[] { "/C" }, out result, out error);
                    if (!string.IsNullOrEmpty(result))
                    {
                        if (result.EndsWith("\r\n"))
                        {
                            commandPath = result.Replace("\r\n", "");
                        }
                    }

                    //-----check each path
                    List <string> architectures = new List <string> {
                        ""
                    };
                    if (Environment.Is64BitOperatingSystem)
                    {
                        architectures.Insert(0, "64");
                    }

                    DirectoryInfo fileInfo = Directory.GetParent(Environment.SystemDirectory);
                    foreach (string architecture in architectures)
                    {
                        foreach (string version in versions)
                        {
                            try
                            {
                                DirectoryInfo[] directoryInfos = fileInfo.GetDirectories(string.Format("{0}*", Path.Combine(string.Format("{0}{1}", path, architecture), version)));
                                if (directoryInfos != null && directoryInfos.Length > 0)
                                {
                                    foreach (DirectoryInfo directoryInfo in directoryInfos)
                                    {
                                        FileInfo[] fileInfos = directoryInfo.GetFiles(executable);
                                        if (fileInfos != null && fileInfos.Length == 1)
                                        {
                                            if (fileInfos[0].FullName != commandPath)
                                            {
                                                Configuration.GeneralOptions.MsBuildOptions.ExePaths.Add(fileInfos[0].FullName);
                                                needsSave = true;
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex) { Trace.WriteLine(ex); }
                        }
                    }

                    //-----add the command path last
                    if (!string.IsNullOrEmpty(commandPath))
                    {
                        Configuration.GeneralOptions.MsBuildOptions.ExePaths.Add(commandPath);
                        needsSave = true;
                    }

                    Configuration.GeneralOptions.MsBuildOptions.ExePaths = Configuration.GeneralOptions.MsBuildOptions.ExePaths.OrderByDescending(s => s).ToList();
                }
                catch (Exception ex) { LoggingManager.Instance.Logger.Error(ex); }
            }
            return(needsSave);
        }