[MonoDevelop] Import Visual Studio .NET Projects

Dean Brettle dean@brettle.com
Thu, 17 Mar 2005 09:13:13 -0500


--=-cQ5dz9MiEZTTKBvz7WYa
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2005-03-16 at 07:56 -0600, Francisco T. Martinez wrote:
> OK.  I have a decent cure for a lot of ailments in the included patch. 

Cool!

> Some of the highlights here are:
> 
> * Mono 2.0 has been commented out until further notice.

Excellent.  That makes all the refs refer to the mono-1.0 assemblies,
which means that I no longer need support for mono-2.0 in order to
import and build cleanly.  Unfortunately, there are still 2 other issues
blocking a clean import and build.

First, one of the projects I'm importing references .\bin
\<AssemblyName>.dll.  The attached patch (to be applied after
Francisco's patch) causes that reference to be converted to an Assembly
reference (with a relative path) instead of a GAC reference.

Second, there is the case-insensitivity issue I've logged at:
http://bugzilla.ximian.com/show_bug.cgi?id=73697
At first, I thought this was a very rare issue, but I've had to
workaround it in 3 of the 13 projects I've imported.  Would a fix
similar to what I describe in the bug be considered for inclusion or
does anyone have a better idea?

Thanks,

--Dean



--=-cQ5dz9MiEZTTKBvz7WYa
Content-Disposition: attachment; filename=monodevelop-relative-assemblies.patch
Content-Type: text/x-patch; name=monodevelop-relative-assemblies.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

--- MsPrjHelper.cs.orig	2005-03-16 23:23:02.000000000 -0500
+++ MsPrjHelper.cs	2005-03-17 08:58:37.000000000 -0500
@@ -454,7 +454,11 @@
 				);
 			
 			// convert backslashes to slashes    		
-			csprojFileName = csprojFileName.Replace("\\", "/");			
+			csprojFileName = csprojFileName.Replace('\\', Path.DirectorySeparatorChar);			
+			string csprojDirName = Path.GetDirectoryName(csprojFileName);
+			if (csprojDirName == null) {
+				csprojDirName = Path.GetPathRoot(csprojFileName);
+			} 
 			Console.WriteLine(String.Format("Will create project filename:{0}", PrjxFileName));
 
 			// Load the csproj
@@ -472,7 +476,7 @@
 			prjxObj.projecttype = "C#";
 
 			prjxObj.Contents = GetContents (csprojObj.CSHARP.Files.Include);
-			prjxObj.References = GetReferences(csprojObj.CSHARP.Build.References);
+			prjxObj.References = GetReferences(csprojObj.CSHARP.Build.References, csprojDirName);
 			prjxObj.DeploymentInformation = new MonoDevelop.Prj2Make.Schema.Prjx.DeploymentInformation();
 			prjxObj.DeploymentInformation.target = "";
 			prjxObj.DeploymentInformation.script = "";
@@ -627,7 +631,7 @@
 			}
 		}
 
-		protected MonoDevelop.Prj2Make.Schema.Prjx.Reference[] GetReferences(MonoDevelop.Prj2Make.Schema.Csproj.Reference[] References)
+		protected MonoDevelop.Prj2Make.Schema.Prjx.Reference[] GetReferences(MonoDevelop.Prj2Make.Schema.Csproj.Reference[] References, string csprojDirName)
 		{
 			MonoDevelop.Prj2Make.Schema.Prjx.Reference[] theReferences = null;
 			int i = 0;
@@ -806,8 +810,19 @@
 						
 						if(bIsWhereExpected == false)
 						{
-							rfOut.refto = Path.GetFileName(rf.HintPath);
-							rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+							// It's not in a standard location.  If it's actually at the location specified 
+							// by the HintPath, add an Assembly reference instead of a GAC reference.
+							// This makes relative references to assemblies work.  If it's not at the
+							// HintPath, add a GAC reference.  The user can then add it to one of the 
+							// standard locations later.
+							string assemblyPath = rf.HintPath.Replace('\\', Path.DirectorySeparatorChar);
+							if (System.IO.File.Exists(Path.Combine(csprojDirName, assemblyPath))) {
+								rfOut.refto = assemblyPath;
+								rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Assembly;
+							} else {
+								rfOut.refto = Path.GetFileName(rf.HintPath);
+								rfOut.type = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceType.Gac;
+							}
 							rfOut.localcopy = MonoDevelop.Prj2Make.Schema.Prjx.ReferenceLocalcopy.True;
 							// increment the iterator value
 							theReferences[i++] = rfOut;

--=-cQ5dz9MiEZTTKBvz7WYa--