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

« back to all changes in this revision

Viewing changes to src/addins/AspNetAddIn/MonoDevelop.AspNet/AspNetAppProject.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// AspNetAppProject.cs: ASP.NET "Web Application" project type
 
3
//
 
4
// Authors:
 
5
//   Michael Hutchinson <m.j.hutchinson@gmail.com>
 
6
//
 
7
// Copyright (C) 2006 Michael Hutchinson
 
8
//
 
9
//
 
10
// This source code is licenced under The MIT License:
 
11
//
 
12
// Permission is hereby granted, free of charge, to any person obtaining
 
13
// a copy of this software and associated documentation files (the
 
14
// "Software"), to deal in the Software without restriction, including
 
15
// without limitation the rights to use, copy, modify, merge, publish,
 
16
// distribute, sublicense, and/or sell copies of the Software, and to
 
17
// permit persons to whom the Software is furnished to do so, subject to
 
18
// the following conditions:
 
19
// 
 
20
// The above copyright notice and this permission notice shall be
 
21
// included in all copies or substantial portions of the Software.
 
22
// 
 
23
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
24
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
25
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
26
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
27
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
28
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
29
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
30
//
 
31
 
 
32
using System;
 
33
using System.IO;
 
34
using System.Xml;
 
35
using System.Collections.Generic;
 
36
using MonoDevelop.Core;
 
37
using MonoDevelop.Core.Gui;
 
38
using MonoDevelop.Core.Execution;
 
39
using MonoDevelop.Core.ProgressMonitoring;
 
40
using MonoDevelop.Projects;
 
41
using MonoDevelop.Projects.Dom;
 
42
using MonoDevelop.Core.Serialization;
 
43
using MonoDevelop.Deployment;
 
44
 
 
45
using MonoDevelop.AspNet.Parser;
 
46
using MonoDevelop.AspNet.Parser.Dom;
 
47
using MonoDevelop.AspNet.Deployment;
 
48
using MonoDevelop.AspNet.Gui;
 
49
 
 
50
namespace MonoDevelop.AspNet
 
51
{
 
52
        [DataInclude (typeof(AspNetAppProjectConfiguration))]
 
53
        public class AspNetAppProject : DotNetProject
 
54
        {
 
55
                [ItemProperty("XspParameters", IsExternal=true)]
 
56
                protected XspParameters xspParameters = new XspParameters ();
 
57
                
 
58
                [ItemProperty ("VerifyCodeBehindFields", IsExternal=true)]
 
59
                protected bool verifyCodeBehindFields = true;
 
60
                
 
61
                [ItemProperty ("VerifyCodeBehindEvents", IsExternal=true)]
 
62
                protected bool verifyCodeBehindEvents = true;
 
63
                
 
64
                [ItemProperty("WebDeployTargets", IsExternal=true)]
 
65
                [ItemProperty ("Target", ValueType=typeof(WebDeployTarget), Scope="*")]
 
66
                protected WebDeployTargetCollection webDeployTargets = new WebDeployTargetCollection ();
 
67
                
 
68
                #region properties
 
69
                
 
70
                public override string ProjectType {
 
71
                        get  { return "AspNetApp"; }
 
72
                }
 
73
                
 
74
                public override bool IsLibraryBasedProjectType {
 
75
                        get { return true; }
 
76
                }
 
77
                
 
78
                protected override void OnEndLoad ()
 
79
                {
 
80
                        base.OnEndLoad ();
 
81
                        
 
82
                        //FIX: old version of MD didn't set CompileTarget to Library for ASP.NET projects, 
 
83
                        // but implicitly assumed they were always libraries. This is not compatible with VS/MSBuild,
 
84
                        // so we automatically "upgrade" this value. 
 
85
                        if (CompileTarget != CompileTarget.Library)
 
86
                                CompileTarget = CompileTarget.Library;
 
87
                }
 
88
                
 
89
                public XspParameters XspParameters {
 
90
                        get { return xspParameters; }
 
91
                }
 
92
                
 
93
                public bool VerifyCodeBehindFields {
 
94
                        get { return verifyCodeBehindFields; }
 
95
                        set { verifyCodeBehindFields = value; }
 
96
                }
 
97
                
 
98
                //TODO: make this do something
 
99
                public bool VerifyCodeBehindEvents {
 
100
                        get { return verifyCodeBehindEvents; }
 
101
                        set { verifyCodeBehindEvents = value; }
 
102
                }
 
103
                
 
104
                public WebDeployTargetCollection WebDeployTargets {
 
105
                        get { return webDeployTargets; }
 
106
                }
 
107
                
 
108
                public override ClrVersion[] SupportedClrVersions {
 
109
                        get {
 
110
                                ClrVersion[] versions = base.SupportedClrVersions;
 
111
                                if (versions == null)
 
112
                                        return null;
 
113
                                
 
114
                                bool ver1 = false, ver2 = false;
 
115
                                foreach (ClrVersion version in versions) {
 
116
                                        if (version == ClrVersion.Net_1_1)
 
117
                                                ver1 = true;
 
118
                                        if (version == ClrVersion.Net_2_0)
 
119
                                                ver2 = true;
 
120
                                }
 
121
                                if (ver1) {
 
122
                                        if (ver2)
 
123
                                                return new ClrVersion[] { ClrVersion.Net_1_1, ClrVersion.Net_2_0 };
 
124
                                        else return new ClrVersion[] { ClrVersion.Net_1_1 };
 
125
                                } else if (ver2) {
 
126
                                        return new ClrVersion[] { ClrVersion.Net_2_0 };
 
127
                                }
 
128
                                return null;
 
129
                        }
 
130
                }
 
131
                
 
132
                #endregion
 
133
                
 
134
                #region constructors
 
135
                
 
136
                public AspNetAppProject ()
 
137
                {
 
138
                }
 
139
                
 
140
                public AspNetAppProject (string languageName)
 
141
                        : base (languageName)
 
142
                {
 
143
                }
 
144
                
 
145
                public AspNetAppProject (string languageName, ProjectCreateInformation info, XmlElement projectOptions)
 
146
                        : base (languageName, info, projectOptions)
 
147
                {
 
148
                }       
 
149
                
 
150
                public override SolutionItemConfiguration CreateConfiguration (string name)
 
151
                {
 
152
                        AspNetAppProjectConfiguration conf = new AspNetAppProjectConfiguration ();
 
153
                        
 
154
                        conf.Name = name;
 
155
                        conf.CompilationParameters = LanguageBinding.CreateCompilationParameters (null);                        
 
156
                        return conf;
 
157
                }
 
158
                
 
159
                #endregion
 
160
                
 
161
                #region build/prebuild/execute
 
162
                
 
163
                
 
164
                protected override BuildResult DoBuild (IProgressMonitor monitor, string configuration)
 
165
                {
 
166
                        //if no files are set to compile, then some compilers will error out
 
167
                        //though this is valid with ASP.NET apps, so we just avoid calling the compiler in this case
 
168
                        bool needsCompile = false;
 
169
                        foreach (ProjectFile pf in Files) {
 
170
                                if (pf.BuildAction == BuildAction.Compile) {
 
171
                                        needsCompile = true;
 
172
                                        break;
 
173
                                }
 
174
                        }
 
175
                        
 
176
                        BuildResult ret;
 
177
                        if (needsCompile)
 
178
                                return base.DoBuild (monitor, configuration);
 
179
                        else
 
180
                                return new BuildResult ();
 
181
                }
 
182
                
 
183
                static bool CheckXsp (string command)
 
184
                {
 
185
                        try {
 
186
                                ProcessWrapper p = Runtime.ProcessService.StartProcess (command, "--version", null, null);
 
187
                                p.WaitForOutput ();
 
188
                                return true;
 
189
                        } catch {
 
190
                                return false;
 
191
                        }
 
192
                }
 
193
                
 
194
                protected override bool OnGetCanExecute (MonoDevelop.Projects.ExecutionContext context, string configuration)
 
195
                {
 
196
                        return context.ExecutionHandlerFactory.SupportsPlatform (ExecutionPlatform.Native);
 
197
                }
 
198
                
 
199
                protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, string config)
 
200
                {
 
201
                        //check XSP is available
 
202
                        
 
203
                        AspNetAppProjectConfiguration configuration = (AspNetAppProjectConfiguration) GetConfiguration (config);
 
204
                        
 
205
                        ClrVersion clrVersion = configuration.ClrVersion;
 
206
                        string xspVersion = (clrVersion == ClrVersion.Net_1_1)? "xsp" : "xsp2";
 
207
                        if (!CheckXsp (xspVersion)) {
 
208
                                monitor.ReportError (string.Format ("The \"{0}\" web server cannot be started. Please ensure that it is installed.",xspVersion), null);
 
209
                                return;
 
210
                        }
 
211
                        
 
212
                        IConsole console = null;
 
213
                        AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);
 
214
                        
 
215
                        try {
 
216
                                IExecutionHandler handler = context.ExecutionHandlerFactory.CreateExecutionHandler ("Native");
 
217
                                if (handler == null)
 
218
                                        throw new Exception ("Could not obtain platform handler.");
 
219
                                
 
220
                                if (configuration.ExternalConsole)
 
221
                                        console = context.ExternalConsoleFactory.CreateConsole (!configuration.PauseConsoleOutput);
 
222
                                else
 
223
                                        console = context.ConsoleFactory.CreateConsole (!configuration.PauseConsoleOutput);
 
224
                        
 
225
                                monitor.Log.WriteLine ("Running web server...");
 
226
                                
 
227
                                //set mono debug mode if project's in debug mode
 
228
                                Dictionary<string, string> envVars = new Dictionary<string,string> (); 
 
229
                                if (configuration.DebugMode)
 
230
                                        envVars ["MONO_OPTIONS"] = "--debug";
 
231
                                
 
232
                                IProcessAsyncOperation op = handler.Execute (xspVersion, XspParameters.GetXspParameters (), BaseDirectory, envVars, console);
 
233
                                operationMonitor.AddOperation (op); //handles cancellation
 
234
                                
 
235
                                //launch a separate thread to detect the running server and launch a web browser
 
236
                                string url = String.Format ("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port);
 
237
                                BrowserLauncherOperation browserLauncher = BrowserLauncher.LaunchWhenReady (url);
 
238
                                operationMonitor.AddOperation (browserLauncher);
 
239
                                
 
240
                                //report errors from the browser launcher
 
241
                                browserLauncher.Completed += delegate (IAsyncOperation blop) {
 
242
                                        if (!blop.Success)
 
243
                                                MessageService.ShowError (
 
244
                                                    GettextCatalog.GetString ("Error launching web browser"),
 
245
                                                    ((BrowserLauncherOperation)blop).Error.ToString ()
 
246
                                                );
 
247
                                };
 
248
                                
 
249
                                op.WaitForCompleted ();
 
250
                                monitor.Log.WriteLine ("The web server exited with code: {0}", op.ExitCode);
 
251
                                
 
252
                                //if server shut down before browser launched, abort browser launch
 
253
                                if (!browserLauncher.IsCompleted) {
 
254
                                        browserLauncher.Cancel ();
 
255
                                        browserLauncher.WaitForCompleted ();
 
256
                                }
 
257
                        } catch (Exception ex) {
 
258
                                monitor.ReportError ("Could not launch web server.", ex);
 
259
                        } finally {
 
260
                                operationMonitor.Dispose ();
 
261
                                if (console != null)
 
262
                                        console.Dispose ();
 
263
                        }
 
264
                }
 
265
                
 
266
                #endregion
 
267
                
 
268
                #region File utility methods
 
269
                
 
270
                public WebSubtype DetermineWebSubtype (ProjectFile file)
 
271
                {
 
272
                        if (LanguageBinding != null && LanguageBinding.IsSourceCodeFile (file.FilePath))
 
273
                                return WebSubtype.Code;
 
274
                        return DetermineWebSubtype (file.Name);
 
275
                }
 
276
                
 
277
                public static WebSubtype DetermineWebSubtype (string fileName)
 
278
                {
 
279
                        string extension = System.IO.Path.GetExtension (fileName);
 
280
                        if (extension == null)
 
281
                                return WebSubtype.None;
 
282
                        extension = extension.ToLower ().TrimStart ('.');
 
283
                        
 
284
                        //NOTE: No way to identify WebSubtype.Code from here
 
285
                        //use the instance method for that
 
286
                        switch (extension)
 
287
                        {
 
288
                        case "aspx":
 
289
                                return WebSubtype.WebForm;
 
290
                        case "master":
 
291
                                return WebSubtype.MasterPage;
 
292
                        case "ashx":
 
293
                                return WebSubtype.WebHandler;
 
294
                        case "ascx":
 
295
                                return WebSubtype.WebControl;
 
296
                        case "asmx":
 
297
                                return WebSubtype.WebService;
 
298
                        case "asax":
 
299
                                return WebSubtype.Global;
 
300
                        case "gif":
 
301
                        case "png":
 
302
                        case "jpg":
 
303
                                return WebSubtype.WebImage;
 
304
                        case "skin":
 
305
                                return WebSubtype.WebSkin;
 
306
                        case "config":
 
307
                                return WebSubtype.Config;
 
308
                        case "browser":
 
309
                                return WebSubtype.BrowserDefinition;
 
310
                        case "axd":
 
311
                                return WebSubtype.Axd;
 
312
                        case "sitemap":
 
313
                                return WebSubtype.Sitemap;
 
314
                        case "css":
 
315
                                return WebSubtype.Css;
 
316
                        case "xhtml":
 
317
                        case "html":
 
318
                        case "htm":
 
319
                                return WebSubtype.Html;
 
320
                        case "js":
 
321
                                return WebSubtype.JavaScript;
 
322
                        default:
 
323
                                return WebSubtype.None;
 
324
                        }
 
325
                }
 
326
                
 
327
                #endregion
 
328
                
 
329
                #region special files
 
330
                
 
331
                #endregion
 
332
                
 
333
                #region Reference handling
 
334
                
 
335
                protected override void OnReferenceAddedToProject (ProjectReferenceEventArgs e)
 
336
                {
 
337
                        //short-circuit if the project is being deserialised
 
338
                        if (Loading) {
 
339
                                base.OnReferenceAddedToProject (e);
 
340
                                return;
 
341
                        }
 
342
                        
 
343
                        UpdateWebConfigRefs ();
 
344
                        
 
345
                        base.OnReferenceAddedToProject (e);
 
346
                }
 
347
                
 
348
                protected override void OnReferenceRemovedFromProject (ProjectReferenceEventArgs e)
 
349
                {
 
350
                        //short-circuit if the project is being deserialised
 
351
                        if (Loading) {
 
352
                                base.OnReferenceAddedToProject (e);
 
353
                                return;
 
354
                        }
 
355
                        
 
356
                        UpdateWebConfigRefs ();
 
357
                        
 
358
                        base.OnReferenceRemovedFromProject (e);
 
359
                }
 
360
                
 
361
                void UpdateWebConfigRefs ()
 
362
                {
 
363
                        List<string> refs = new List<string> ();
 
364
                        foreach (ProjectReference reference in References) {
 
365
                                //local copied assemblies are copied to the bin directory so ASP.NET references them automatically
 
366
                                if (reference.LocalCopy && (reference.ReferenceType == ReferenceType.Project || reference.ReferenceType == ReferenceType.Assembly))
 
367
                                        continue;
 
368
                                if (string.IsNullOrEmpty (reference.Reference))
 
369
                                        continue;
 
370
                                //these assemblies are referenced automatically by ASP.NET
 
371
                                if (IsSystemReference (reference.Reference))
 
372
                                    continue;
 
373
                                //bypass non dotnet projects
 
374
                                if ((reference.ReferenceType == ReferenceType.Project) &&
 
375
                                    (!(reference.OwnerProject.ParentSolution.FindProjectByName (reference.Reference) is DotNetProject)))
 
376
                                                continue;
 
377
                                refs.Add (reference.Reference);
 
378
                        }
 
379
                                                
 
380
                        string webConfigPath = WebConfigPath;
 
381
                        if (!File.Exists (webConfigPath))
 
382
                                return;
 
383
                        
 
384
                        MonoDevelop.Projects.Text.IEditableTextFile textFile = 
 
385
                                MonoDevelop.DesignerSupport.OpenDocumentFileProvider.Instance.GetEditableTextFile (webConfigPath);
 
386
                        //use textfile API because it's write safe (writes out to another file then moves)
 
387
                        if (textFile == null)
 
388
                                textFile = MonoDevelop.Projects.Text.TextFile.ReadFile (webConfigPath);
 
389
                                
 
390
                        //can't use System.Web.Configuration.WebConfigurationManager, as it can only access virtual paths within an app
 
391
                        //so need full manual handling
 
392
                        try {
 
393
                                System.Xml.XmlDocument doc = new XmlDocument ();
 
394
                                
 
395
                                //FIXME: PreserveWhitespace doesn't handle whitespace in attribute lists
 
396
                                //doc.PreserveWhitespace = true;
 
397
                                doc.LoadXml (textFile.Text);
 
398
                                
 
399
                                //hunt our way to the assemblies element, creating elements if necessary
 
400
                                XmlElement configElement = doc.DocumentElement;
 
401
                                if (configElement == null || string.Compare (configElement.Name, "configuration", StringComparison.InvariantCultureIgnoreCase) != 0) {
 
402
                                        configElement = (XmlElement) doc.AppendChild (doc.CreateNode (XmlNodeType.Document, "configuration", null));
 
403
                                }
 
404
                                XmlElement webElement = GetNamedXmlElement (doc, configElement, "system.web");                  
 
405
                                XmlElement compilationNode = GetNamedXmlElement (doc, webElement, "compilation");
 
406
                                XmlElement assembliesNode = GetNamedXmlElement (doc, compilationNode, "assemblies");
 
407
                                
 
408
                                List<XmlNode> existingAdds = new List<XmlNode> ();
 
409
                                foreach (XmlNode node in assembliesNode)
 
410
                                        if (string.Compare (node.Name, "add", StringComparison.InvariantCultureIgnoreCase) == 0)
 
411
                                            existingAdds.Add (node);
 
412
                                
 
413
                                //add refs to the doc if they're not in it
 
414
                                foreach (string reference in refs) {
 
415
                                        int index = 0;
 
416
                                        bool found = false;
 
417
                                        while (index < existingAdds.Count) {
 
418
                                                XmlNode node = existingAdds[index];
 
419
                                                XmlAttribute att = (XmlAttribute) node.Attributes.GetNamedItem ("assembly");
 
420
                                                if (att == null)
 
421
                                                        continue;
 
422
                                                string refAtt = att.Value;
 
423
                                                if (refAtt != null && refAtt == reference) {
 
424
                                                        existingAdds.RemoveAt (index);
 
425
                                                        found = true;
 
426
                                                        break;
 
427
                                                } else {
 
428
                                                        index++;
 
429
                                                }
 
430
                                        }
 
431
                                        if (!found) {
 
432
                                                XmlElement newAdd = doc.CreateElement ("add");
 
433
                                                XmlAttribute newAtt = doc.CreateAttribute ("assembly");
 
434
                                                newAtt.Value = reference;
 
435
                                                newAdd.Attributes.Append (newAtt);
 
436
                                                assembliesNode.AppendChild (newAdd);
 
437
                                        }
 
438
                                }
 
439
                                
 
440
                                //any nodes that weren't removed from the existingAdds list are old/redundant, so remove from doc
 
441
                                foreach (XmlNode node in existingAdds)
 
442
                                        assembliesNode.RemoveChild (node);
 
443
                                
 
444
                                using (StringWriter writer = new StringWriter ()) {
 
445
                                        doc.Save (writer);
 
446
                                        textFile.Text = writer.ToString ();
 
447
                                }
 
448
                                MonoDevelop.Projects.Text.TextFile tf = textFile as MonoDevelop.Projects.Text.TextFile;
 
449
                                if (tf != null)
 
450
                                        tf.Save ();
 
451
                        } catch (Exception e) {
 
452
                                LoggingService.LogWarning ("Could not modify application web.config in project " + this.Name, e); 
 
453
                        }
 
454
                }
 
455
                
 
456
                
 
457
                XmlElement GetNamedXmlElement (XmlDocument doc, XmlElement parent, string name)
 
458
                {
 
459
                        XmlElement result = null;
 
460
                        foreach (XmlNode node in parent.ChildNodes) {
 
461
                                XmlElement elem = node as XmlElement;
 
462
                                if (elem != null && string.Compare (elem.Name, name, StringComparison.InvariantCultureIgnoreCase) == 0) {
 
463
                                        result = elem;
 
464
                                        break;
 
465
                                }
 
466
                        }
 
467
                        if (result == null) {
 
468
                                result = (XmlElement) parent.AppendChild (doc.CreateElement (name));
 
469
                        }
 
470
                        return result;
 
471
                }
 
472
                
 
473
                string WebConfigPath {
 
474
                        get { return Path.Combine (this.BaseDirectory, "web.config"); }
 
475
                }
 
476
                
 
477
                bool IsSystemReference (string reference)
 
478
                {
 
479
                        foreach (string defaultPrefix in defaultAssemblyRefPrefixes)
 
480
                                if (reference.StartsWith (defaultPrefix))
 
481
                                        return true;
 
482
                        return false;
 
483
                }
 
484
                
 
485
                static string[] defaultAssemblyRefPrefixes = new string[] {
 
486
                        "mscorlib", 
 
487
                        "System,",
 
488
                        "System.Configuration,",
 
489
                        "System.Web,",
 
490
                        "System.Data,",
 
491
                        "System.Web.Services,",
 
492
                        "System.Xml,",
 
493
                        "System.Drawing,",
 
494
                        "System.EnterpriseServices,",
 
495
                        "System.Web.Mobile,",
 
496
                };
 
497
                
 
498
                #endregion
 
499
                
 
500
                #region File event handlers
 
501
                
 
502
                protected override void OnFileAddedToProject (ProjectFileEventArgs e)
 
503
                {
 
504
                        //short-circuit if the project is being deserialised
 
505
                        if (Loading) {
 
506
                                base.OnFileAddedToProject (e);
 
507
                                return;
 
508
                        }
 
509
                        
 
510
                        IEnumerable<string> filesToAdd = MonoDevelop.DesignerSupport.CodeBehind.GuessDependencies
 
511
                                (this, e.ProjectFile, groupedExtensions);
 
512
                        
 
513
                        if (Path.GetFullPath (e.ProjectFile.FilePath) == Path.GetFullPath (WebConfigPath))
 
514
                                UpdateWebConfigRefs ();
 
515
                        
 
516
                        //let the base fire the event before we add files
 
517
                        //don't want to fire events out of order of files being added
 
518
                        base.OnFileAddedToProject (e);
 
519
                        
 
520
                        //make sure that the parent and child files are in the project
 
521
                        if (filesToAdd != null) {
 
522
                                foreach (string file in filesToAdd) {
 
523
                                        //NOTE: this only adds files if they are not already in the project
 
524
                                        AddFile (file);
 
525
                                }
 
526
                        }
 
527
                }
 
528
                
 
529
                public override string GetDefaultBuildAction (string fileName)
 
530
                {
 
531
                        
 
532
                        WebSubtype type = DetermineWebSubtype (fileName);
 
533
                        if (type == WebSubtype.Code)
 
534
                                return BuildAction.Compile;
 
535
                        if (type != WebSubtype.None)
 
536
                                return BuildAction.Content;
 
537
                        else
 
538
                                return base.GetDefaultBuildAction (fileName);
 
539
                }
 
540
                
 
541
                static string[] groupedExtensions =  { ".aspx", ".master", ".ashx", ".ascx", ".asmx", ".asax" };
 
542
                
 
543
                #endregion
 
544
                
 
545
                public List<string> GetNotPresentSpecialDirectories ()
 
546
                {
 
547
                        List<string> notPresent = new List<string> ();
 
548
                        
 
549
                        if (TargetFramework.ClrVersion == MonoDevelop.Core.ClrVersion.Net_2_0)
 
550
                                foreach (string dir in specialDirs20)
 
551
                                        if (Files.GetFile (Path.Combine (BaseDirectory, dir)) == null)
 
552
                                                notPresent.Add (dir);
 
553
                        
 
554
                        return notPresent;
 
555
                }
 
556
        
 
557
                static readonly string [] specialDirs20 = new string [] {
 
558
                        "App_Code",
 
559
                        "App_Themes",
 
560
                        "App_Browsers",
 
561
                        "App_Data",
 
562
                        "App_WebReferences",
 
563
                        "App_Resources",
 
564
                        "App_LocalResources",
 
565
                        "App_GlobalResources",          
 
566
                };
 
567
                
 
568
                protected override IList<string> GetCommonBuildActions ()
 
569
                {
 
570
                        return new string[] {
 
571
                                BuildAction.None,
 
572
                                BuildAction.Compile,
 
573
                                BuildAction.Content,
 
574
                                BuildAction.EmbeddedResource,
 
575
                        };
 
576
                }
 
577
 
 
578
        }
 
579
        
 
580
        public enum WebSubtype
 
581
        {
 
582
                None = 0,
 
583
                Code,
 
584
                WebForm,
 
585
                WebService,
 
586
                WebControl,
 
587
                MasterPage,
 
588
                WebHandler,
 
589
                WebSkin,
 
590
                WebImage,
 
591
                BrowserDefinition,
 
592
                Sitemap,
 
593
                Global,
 
594
                Config,
 
595
                Axd,
 
596
                Css,
 
597
                Html,
 
598
                JavaScript,
 
599
        }
 
600
        
 
601
        
 
602
}