Beispiel #1
0
        public static bool ExtractPackage(DTE dte, string toolPath, UnpackSettings unpackSettings, string commandArgs)
        {
            var command = new SolutionPackagerCommand
            {
                Action       = SolutionPackagerAction.Extract.ToString(),
                CommandArgs  = commandArgs,
                ToolPath     = toolPath,
                SolutionName = unpackSettings.CrmSolution.Name
            };

            ExecuteSolutionPackager(command);

            var solutionFileDelete = RemoveDeletedItems(unpackSettings.ExtractedFolder.FullName,
                                                        unpackSettings.Project.ProjectItems,
                                                        unpackSettings.SolutionPackageConfig.packagepath);
            var solutionFileAddChange = ProcessDownloadedSolution(unpackSettings.ExtractedFolder,
                                                                  unpackSettings.ProjectPackageFolder,
                                                                  unpackSettings.Project.ProjectItems);

            FileSystem.DeleteDirectory(unpackSettings.ExtractedFolder.FullName);

            if (!unpackSettings.SaveSolutions)
            {
                return(true);
            }

            //Solution change or file not present
            var solutionChange = solutionFileDelete || solutionFileAddChange;
            var solutionStored = StoreSolutionFile(unpackSettings, solutionChange);

            return(solutionStored);
        }
Beispiel #2
0
        private static string CreateExtractCommandArgs(UnpackSettings unpackSettings)
        {
            var command = new StringBuilder();

            command.Append(" /action: Extract");
            command.Append($" /zipfile: \"{unpackSettings.DownloadedZipPath}\"");
            command.Append($" /folder: \"{unpackSettings.ExtractedFolder.FullName}\"");
            command.Append(" /clobber");

            // Add a mapping file which should be in the root folder of the project and be named mapping.xml
            if (unpackSettings.SolutionPackageConfig.map != null && unpackSettings.UseMapFile)
            {
                MapFile.Create(unpackSettings.SolutionPackageConfig, Path.Combine(unpackSettings.ProjectPath, ExtensionConstants.SolutionPackagerMapFile));
                if (File.Exists(Path.Combine(unpackSettings.ProjectPath, ExtensionConstants.SolutionPackagerMapFile)))
                {
                    command.Append($" /map: \"{Path.Combine(unpackSettings.ProjectPath, ExtensionConstants.SolutionPackagerMapFile)}\"");
                }
            }

            // Write Solution Package output to a log file named SolutionPackager.log in the root folder of the project
            if (unpackSettings.EnablePackagerLogging)
            {
                command.Append($" /log: \"{Path.Combine(unpackSettings.ProjectPath, ExtensionConstants.SolutionPackagerLogFile)}\"");
            }

            // Unpack managed or unmanaged
            command.Append($" /packagetype:{unpackSettings.SolutionPackageConfig.packagetype}");

            return(command.ToString());
        }
Beispiel #3
0
        private static bool StoreSolutionFile(UnpackSettings unpackSettings, bool solutionChange)
        {
            try
            {
                var filename = Path.GetFileName(unpackSettings.DownloadedZipPath);
                if (string.IsNullOrEmpty(filename))
                {
                    OutputLogger.WriteToOutputWindow($"{Resource.ErrorMessage_ErrorGettingFileNameFromTemp}: {unpackSettings.DownloadedZipPath}", MessageType.Error);
                    return(false);
                }

                var newSolutionFile = Path.Combine(unpackSettings.ProjectSolutionFolder, filename);

                if (!solutionChange && File.Exists(newSolutionFile))
                {
                    return(true);
                }

                if (File.Exists(newSolutionFile))
                {
                    File.Delete(newSolutionFile);
                }

                File.Move(unpackSettings.DownloadedZipPath, newSolutionFile);

                unpackSettings.Project.ProjectItems.AddFromFile(newSolutionFile);

                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorAddingSolutionFileProject, ex);

                return(false);
            }
        }
Beispiel #4
0
        public static string GetExtractCommandArgs(UnpackSettings unpackSettings)
        {
            var commandArgs = CreateExtractCommandArgs(unpackSettings);

            return(commandArgs);
        }