2 // SilverlightMSBuildProjectExtension.cs
5 // Ankit Jain <jankit@novell.com>
7 // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using MonoDevelop
.Core
;
30 using MonoDevelop
.Projects
;
35 namespace MonoDevelop
.Prj2Make
38 public class SilverlightMSBuildProjectExtension
: MSBuildProjectExtension
40 const string myguid
= "{A1591282-1198-4647-A2B1-27E5FF5F6F3B}";
42 public override string TypeGuid
{
43 get { return myguid; }
46 public override string Name
{
47 get { return "Silverlight";}
50 public override bool Supports (string type_guid
, string filename
, string type_guids
)
52 return (String
.Compare (type_guid
, myguid
, true) == 0);
55 public override DotNetProject
CreateProject (string type_guid
, string filename
, string type_guids
)
57 if (!Supports (type_guid
, filename
, type_guids
))
58 throw new InvalidOperationException (String
.Format ("Project of type guid = {0} not supported by this extension.", type_guid
));
60 int semicolon
= type_guids
.IndexOf (';');
61 if (semicolon
< 0 || semicolon
== type_guids
.Length
)
62 throw new Exception (String
.Format ("Invalid type guid. Missing super-type guid"));
64 //FIXME: this shouldn't be required
65 type_guids
= type_guids
.Substring (semicolon
+ 1);
66 type_guid
= type_guids
.Split (';') [0];
67 return base.CreateProject (type_guid
, filename
, type_guids
);
70 public override void ReadItemGroup (MSBuildData data
, DotNetProject project
, DotNetProjectConfiguration globalConfig
, string include
, string basePath
, XmlNode node
, IProgressMonitor monitor
)
72 if (node
.LocalName
== "SilverlightPage") {
73 //FIXME: this should be available only for
74 //<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
77 // <Generator>MSBuild:Compile</Generator>
78 string path
= Utils
.GetValidPath (monitor
, basePath
, include
);
82 ProjectFile pf
= project
.AddFile (path
, BuildAction
.EmbeddedResource
);
83 pf
.ExtendedProperties
["MonoDevelop.MSBuildFileFormat.SilverlightPage"] = String
.Empty
;
84 data
.ProjectFileElements
[pf
] = (XmlElement
) node
;
86 // Add the corresponding %.g.cs to the project, we'll skip this
87 // when saving the project file
88 pf
= project
.AddFile (path
+ ".g.cs", BuildAction
.Compile
);
89 pf
.ExtendedProperties
["MonoDevelop.MSBuildFileFormat.SilverlightGeneratedFile"] = String
.Empty
;
90 data
.ProjectFileElements
[pf
] = (XmlElement
) node
;
92 base.ReadItemGroup (data
, project
, globalConfig
, include
, basePath
, node
, monitor
);
96 public override XmlElement
FileToXmlElement (MSBuildData d
, Project project
, ProjectFile projectFile
)
98 if (projectFile
.ExtendedProperties
["MonoDevelop.MSBuildFileFormat.SilverlightGeneratedFile"] != null)
99 //Ignore the generated %.xaml.g.cs files
102 return base.FileToXmlElement (d
, project
, projectFile
);
105 public override string GetGuidChain (DotNetProject project
)