~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectConvertTool.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
using System;
30
30
using System.IO;
 
31
using System.Collections.Generic;
31
32
using MonoDevelop.Core;
32
33
using MonoDevelop.Core.ProgressMonitoring;
33
34
 
46
47
                                Console.WriteLine ("  -d:<dest-path>      Directory where the project will be exported.");
47
48
                                Console.WriteLine ("  -f:\"<format-name>\"  Format to which export the project or solution.");
48
49
                                Console.WriteLine ("  -l                  Show a list of all allowed target formats.");
 
50
                                Console.WriteLine ("  -p:<project-name>   When exporting a solution, name of a project to be");
 
51
                                Console.WriteLine ("                      included in the export. It can be specified multiple");
 
52
                                Console.WriteLine ("                      times.");
49
53
                                Console.WriteLine ("");
50
54
                                Console.WriteLine ("  The format name is optional. A list of allowed file formats will be");
51
55
                                Console.WriteLine ("  shown if none is provided.");
57
61
                        string destPath = null;
58
62
                        string formatName = null;
59
63
                        bool formatList = false;
 
64
                        List<string> projects = new List<string> ();
 
65
                        string[] itemsToExport = null;
60
66
                        
61
67
                        foreach (string s in arguments)
62
68
                        {
64
70
                                        destPath = s.Substring (3);
65
71
                                else if (s.StartsWith ("-f:"))
66
72
                                        formatName = s.Substring (3);
 
73
                                else if (s.StartsWith ("-p:"))
 
74
                                        projects.Add (s.Substring (3));
67
75
                                else if (s == "-l")
68
76
                                        formatList = true;
69
77
                                else if (projectFile != null) {
90
98
                        
91
99
                        
92
100
                        object item;
93
 
                        if (Services.ProjectService.IsWorkspaceItemFile (projectFile))
 
101
                        if (Services.ProjectService.IsWorkspaceItemFile (projectFile)) {
94
102
                                item = Services.ProjectService.ReadWorkspaceItem (monitor, projectFile);
95
 
                        else
 
103
                                if (projects.Count > 0) {
 
104
                                        Solution sol = item as Solution;
 
105
                                        if (sol == null) {
 
106
                                                Console.WriteLine ("The -p option can only be used when exporting a solution.");
 
107
                                                return 1;
 
108
                                        }
 
109
                                        for (int n=0; n<projects.Count; n++) {
 
110
                                                string pname = projects [n];
 
111
                                                if (pname.Length == 0) {
 
112
                                                        Console.WriteLine ("Project name not specified in -p option.");
 
113
                                                        return 1;
 
114
                                                }
 
115
                                                Project p = sol.FindProjectByName (pname);
 
116
                                                if (p == null) {
 
117
                                                        Console.WriteLine ("Project '" + pname + "' not found in solution.");
 
118
                                                        return 1;
 
119
                                                }
 
120
                                                projects[n] = p.ItemId;
 
121
                                        }
 
122
                                        itemsToExport = projects.ToArray ();
 
123
                                }
 
124
                        }
 
125
                        else {
 
126
                                if (projects.Count > 0) {
 
127
                                        Console.WriteLine ("The -p option can't be used when exporting a single project");
 
128
                                        return 1;
 
129
                                }
96
130
                                item = Services.ProjectService.ReadSolutionItem (monitor, projectFile);
 
131
                        }
97
132
                        
98
133
                        FileFormat[] formats = Services.ProjectService.FileFormats.GetFileFormatsForObject (item);
99
134
                        
142
177
                                destPath = Path.GetDirectoryName (projectFile);
143
178
                        destPath = FileService.GetFullPath (destPath);
144
179
                        
145
 
                        string ofile = Services.ProjectService.Export (monitor, projectFile, destPath, format);
 
180
                        string ofile = Services.ProjectService.Export (monitor, projectFile, itemsToExport, destPath, format);
146
181
                        if (ofile != null) {
147
182
                                Console.WriteLine ("Saved file: " + ofile);
148
183
                                return 0;