diff options
author | Lluis Sanchez <lluis@novell.com> | 2009-08-20 19:46:43 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2009-08-20 19:46:43 +0400 |
commit | 54044e86c56276418f2ed124b349e34d6c59941f (patch) | |
tree | b460284ecd7e30a9d573f6ed8040fe1c5e56088d /main/src/addins/prj2make-sharp-lib | |
parent | 70f5dbcb2d1d706ba56742c6a83df10e4c8b3382 (diff) |
* CsprojInfo.cs:
* MsPrjHelper.cs:
* VS2003ProjectFileFormat.cs: Make sure the project has the 2003
format before trying to import it. Properly import assembly
references.
svn path=/trunk/monodevelop/; revision=140344
Diffstat (limited to 'main/src/addins/prj2make-sharp-lib')
4 files changed, 43 insertions, 12 deletions
diff --git a/main/src/addins/prj2make-sharp-lib/ChangeLog b/main/src/addins/prj2make-sharp-lib/ChangeLog index c40d9538fb..b02c18f593 100644 --- a/main/src/addins/prj2make-sharp-lib/ChangeLog +++ b/main/src/addins/prj2make-sharp-lib/ChangeLog @@ -1,3 +1,11 @@ +2009-08-20 Lluis Sanchez Gual <lluis@novell.com> + + * CsprojInfo.cs: + * MsPrjHelper.cs: + * VS2003ProjectFileFormat.cs: Make sure the project has the + 2003 format before trying to import it. Properly import + assembly references. + 2009-08-13 Lluis Sanchez Gual <lluis@novell.com> * MsPrjHelper.cs: Use the new AssemblyContext class to query diff --git a/main/src/addins/prj2make-sharp-lib/CsprojInfo.cs b/main/src/addins/prj2make-sharp-lib/CsprojInfo.cs index 64fad65959..3b965fba9f 100644 --- a/main/src/addins/prj2make-sharp-lib/CsprojInfo.cs +++ b/main/src/addins/prj2make-sharp-lib/CsprojInfo.cs @@ -5,7 +5,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Xml; using System.Xml.Serialization; - +using MonoDevelop.Projects; namespace MonoDevelop.Prj2Make { @@ -21,6 +21,7 @@ namespace MonoDevelop.Prj2Make public string src; private bool m_bAllowUnsafeCode; private MonoDevelop.Prj2Make.Schema.Csproj.VisualStudioProject m_projObject; + public bool NeedsConversion = true; public string ext_refs = ""; public string switches = ""; @@ -62,8 +63,14 @@ namespace MonoDevelop.Prj2Make // loads the file in order to deserialize and // build the object graph - try + try { + FileFormat format = Services.ProjectService.FileFormats.GetFileFormatForFile (csprojpath, typeof(SolutionEntityItem)); + if (format != null && format.Id != "VS2003ProjectFileFormat") { + NeedsConversion = false; + return; + } + m_projObject = LoadPrjFromFile (csprojpath); } catch (Exception exc) diff --git a/main/src/addins/prj2make-sharp-lib/MsPrjHelper.cs b/main/src/addins/prj2make-sharp-lib/MsPrjHelper.cs index 30e51a1b31..5cb567c523 100644 --- a/main/src/addins/prj2make-sharp-lib/MsPrjHelper.cs +++ b/main/src/addins/prj2make-sharp-lib/MsPrjHelper.cs @@ -170,9 +170,13 @@ namespace MonoDevelop.Prj2Make } } - public DotNetProject CreatePrjxFromCsproj (string csprojFileName, IProgressMonitor monitor) + public SolutionEntityItem CreatePrjxFromCsproj (string csprojFileName, IProgressMonitor monitor) { try { + FileFormat format = Services.ProjectService.FileFormats.GetFileFormatForFile (csprojFileName, typeof(SolutionEntityItem)); + if (format != null && format.Id != "VS2003ProjectFileFormat") + return (SolutionEntityItem) Services.ProjectService.ReadSolutionItem (monitor, csprojFileName); + MonoDevelop.Prj2Make.Schema.Csproj.VisualStudioProject csprojObj = null; monitor.BeginTask (GettextCatalog.GetString ("Importing project: ") + csprojFileName, 4); @@ -202,7 +206,7 @@ namespace MonoDevelop.Prj2Make GetContents (prjxObj, csprojObj.CSHARP.Files.Include, prjxObj.Files, monitor); monitor.Step (1); - GetReferences (csprojObj.CSHARP.Build.References, prjxObj.References, monitor); + GetReferences (prjxObj, csprojObj.CSHARP.Build.References, prjxObj.References, monitor); monitor.Step (1); prjxObj.Configurations.Clear (); @@ -248,7 +252,12 @@ namespace MonoDevelop.Prj2Make monitor.ReportWarning (GettextCatalog.GetString ("Project file not found: ") + pi.csprojpath); continue; } - DotNetProject prj = CreatePrjxFromCsproj (mappedPath, monitor); + SolutionEntityItem prj; + if (pi.NeedsConversion) + prj = CreatePrjxFromCsproj (mappedPath, monitor); + else + prj = (DotNetProject) Services.ProjectService.ReadSolutionItem (monitor, mappedPath); + if (prj == null) return null; @@ -276,7 +285,7 @@ namespace MonoDevelop.Prj2Make } } - protected void GetReferences (MonoDevelop.Prj2Make.Schema.Csproj.Reference[] References, ProjectReferenceCollection references, IProgressMonitor monitor) + protected void GetReferences (Project project, MonoDevelop.Prj2Make.Schema.Csproj.Reference[] References, ProjectReferenceCollection references, IProgressMonitor monitor) { if (References == null || References.Length == 0) return; @@ -332,6 +341,14 @@ namespace MonoDevelop.Prj2Make string oref = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyFullName (rname, fx); if (oref == null) { + if (rf.HintPath != null) { + string asm = MapPath (project.ItemDirectory, rf.HintPath); + if (!System.IO.File.Exists (asm)) + monitor.ReportWarning (GettextCatalog.GetString ("Referenced assembly not found: ") + asm); + ProjectReference aref = new ProjectReference (MonoDevelop.Projects.ReferenceType.Assembly, asm); + references.Add (aref); + continue; + } monitor.ReportWarning (GettextCatalog.GetString ("Assembly reference could not be imported: ") + rf.AssemblyName); continue; } diff --git a/main/src/addins/prj2make-sharp-lib/VS2003ProjectFileFormat.cs b/main/src/addins/prj2make-sharp-lib/VS2003ProjectFileFormat.cs index fa40bfeaa2..b6153d1e9c 100644 --- a/main/src/addins/prj2make-sharp-lib/VS2003ProjectFileFormat.cs +++ b/main/src/addins/prj2make-sharp-lib/VS2003ProjectFileFormat.cs @@ -119,7 +119,7 @@ namespace MonoDevelop.Prj2Make if (choice == TargetConvert.None) throw new InvalidOperationException ("VS2003 projects are not supported natively."); - DotNetProject project = ImportCsproj (fileName); + SolutionEntityItem project = ImportCsproj (fileName); project.FileName = fileName; if (choice == TargetConvert.MonoDevelop) { @@ -132,7 +132,7 @@ namespace MonoDevelop.Prj2Make return project; } else { - DotNetProject project = ImportCsproj (fileName); + SolutionEntityItem project = ImportCsproj (fileName); project.FileName = fileName; return project; } @@ -160,9 +160,9 @@ namespace MonoDevelop.Prj2Make return ImportSln (fileName); }
- internal DotNetProject ImportCsproj (FilePath fileName) + internal SolutionEntityItem ImportCsproj (FilePath fileName) { - DotNetProject project = null; + SolutionEntityItem project = null; SlnMaker slnmaker = new SlnMaker (); try { IProgressMonitor m = IdeApp.IsInitialized ? GuiHelper.CreateProgressMonitor () : new ConsoleProgressMonitor (); @@ -179,7 +179,6 @@ namespace MonoDevelop.Prj2Make public void ConvertToFormat (object obj) { - throw new NotSupportedException (); }
public List<FilePath> GetItemFiles (object obj) @@ -254,7 +253,7 @@ namespace MonoDevelop.Prj2Make TargetConvert QueryConversion (string text) { AlertButton monodevelop = new AlertButton (GettextCatalog.GetString ("Convert to MonoDevelop")); - AlertButton vs2005 = new AlertButton (GettextCatalog.GetString ("Convert to Visual Studio 2005")); + AlertButton vs2005 = new AlertButton (GettextCatalog.GetString ("Convert to MSBuild")); AlertButton choice = MessageService.AskQuestion (text, GettextCatalog.GetString ("Converting to Visual Studio 2005 format will overwrite existing files."), |