Bug 146 - Directories with similar names (differing only by case) can confuse MonoDevelop when loading a .csproj file containing <Link> elements
Summary: Directories with similar names (differing only by case) can confuse MonoDevel...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: 2.6 Beta 3
Hardware: PC Linux
: Lowest normal
Target Milestone: ---
Assignee: Alan McGovern
URL:
Depends on:
Blocks:
 
Reported: 2011-08-02 12:28 UTC by Robin Munn
Modified: 2011-12-13 06:28 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Robin Munn 2011-08-02 12:28:16 UTC
While trying to load a .csproj file from the open-source WeSay project (http://wesay.org/), I discovered that MonoDevelop gets quite confused if you have two directories named "projects" and "Projects". The WeSay source code was inside "projects", but MonoDevelop was looking for certain files inside the "Projects" directory instead.

Steps to reproduce:

1) Create two directories in your $HOME, called "projects" and "Projects".
2) Somewhere under "projects", run "hg clone http://hg.palaso.org/wesay". (My copy of WeSay's Mercurial repo ended up under /home/munnr/projects/wesay/hg/upstream).
3) Open the src/WeSay.sln solution file from your copy of WeSay's Mercurial repo (on my system, /home/munnr/projects/wesay/hg/upstream/src/WeSay.sln).
4) Note the two errors, in src/WeSay.App/WeSay.App.csproj and src/WeSay.Foundation/WeSay.Foundation.csproj.

When I did this, I got the following error:

ERROR [2011-08-02 11:08:04Z]: Error while trying to load the project /home/munnr/projects/wesay/hg/upstream/src/WeSay.Foundation/WeSay.Foundation.csproj
System.ArgumentException: value
  at MonoDevelop.Projects.ProjectFile.set_Link (FilePath value) [0x0005c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs:256 
  at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.ReadProjectFile (MonoDevelop.Core.Serialization.DataSerializer ser, MonoDevelop.Projects.Project project, MonoDevelop.Projects.Formats.MSBuild.MSBuildItem buildItem, System.Type type) [0x00204] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs:1342 
  at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.ReadItem (MonoDevelop.Projects.Formats.MSBuild.MSBuildSerializer ser, MonoDevelop.Projects.Formats.MSBuild.MSBuildItem buildItem) [0x002d3] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs:549 
  at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.Load (IProgressMonitor monitor, MonoDevelop.Projects.Formats.MSBuild.MSBuildProject msproject) [0x00086] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs:348 
  at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectHandler.Load (IProgressMonitor monitor, System.String fileName, System.String language, System.Type itemClass) [0x00168] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectHandler.cs:274 
  at MonoDevelop.Projects.Extensions.DotNetProjectNode.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, System.String itemGuid) [0x00015] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/DotNetProjectNode.cs:66 
  at MonoDevelop.Projects.Formats.MSBuild.MSBuildProjectService.LoadItem (IProgressMonitor monitor, System.String fileName, System.String typeGuid, System.String itemGuid) [0x00024] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/MSBuildProjectService.cs:91 
  at MonoDevelop.Projects.Formats.MSBuild.SlnFileFormat+<LoadSolution>c__AnonStoreyA5.<>m__6D (IProgressMonitor , System.String ) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs:744 
  at MonoDevelop.Projects.DefaultProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs:672 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Autotools.MakefileProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/addins/MonoDevelop.Autotools/MakefileProjectServiceExtension.cs:69 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Projects.CompiledAssemblyExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x0003e] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/CompiledAssemblyProject.cs:223 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName) [0x00000] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:102 
  at MonoDevelop.Projects.ProjectServiceExtension.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x0000c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectServiceExtension.cs:93 
  at MonoDevelop.Projects.Extensions.ProjectExtensionUtil.LoadSolutionItem (IProgressMonitor monitor, System.String fileName, MonoDevelop.Projects.Extensions.ItemLoadCallback callback) [0x00016] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Extensions/ProjectExtensionUtil.cs:59 
  at MonoDevelop.Projects.Formats.MSBuild.SlnFileFormat.LoadSolution (MonoDevelop.Projects.Solution sol, System.String fileName, MonoDevelop.Projects.Formats.MSBuild.MSBuildFileFormat format, IProgressMonitor monitor) [0x004ba] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MSBuild/SlnFileFormat.cs:743 

Same error for the WeSay.App.csproj file, so I won't paste that traceback here since it's identical other than the filename.

Now, "System.ArgumentException: value" wasn't very informative, so I edited /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs and removed the quotes around "value" in the throw statement on line 252, so that it would include the actual value in the error message instead of the uninformative string "value". The result was:

ERROR [2011-08-02 11:08:04Z]: Error while trying to load the project /home/munnr/projects/wesay/hg/upstream/src/WeSay.Foundation/WeSay.Foundation.csproj
System.ArgumentException: ../../../../../../Projects/wesay/hg/upstream/src/WeSay.Foundation/icudt40.dll
  at MonoDevelop.Projects.ProjectFile.set_Link (FilePath value) [0x0005c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs:256 
(rest of traceback trimmed since it's identical to what came before)

and

ERROR [2011-08-02 11:08:04Z]: Error while trying to load the project /home/munnr/projects/wesay/hg/upstream/src/WeSay.App/WeSay.App.csproj
System.ArgumentException: ../../../../../../Projects/wesay/hg/upstream/src/WeSay.App/plift2html.xsl
  at MonoDevelop.Projects.ProjectFile.set_Link (FilePath value) [0x0005c] in /home/munnr/projects/wesay/tmp/build/monodevelop-2.5.92/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectFile.cs:256 
(rest of traceback trimmed since it's identical to what came before)

The offending filenames come from the following sections in the .csproj files:

src/WeSay.App/WeSay.App.csproj:
  <ItemGroup>
    <EmbeddedResource Include="..\Addin.Transform\plift2html.xsl">
      <Link>plift2html.xsl</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </EmbeddedResource>
  </ItemGroup>

src/WeSay.Foundation/WeSay.Foundation.csproj:
  <ItemGroup>
    <Content Include="..\..\lib\net2.0\icudt40.dll">
      <Link>icudt40.dll</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="..\..\lib\net2.0\icuin40.dll">
      <Link>icuin40.dll</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="..\..\lib\net2.0\icuuc40.dll">
      <Link>icuuc40.dll</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

These two sections also happen to be the only place in all of WeSay's .csproj files where the <Link> element is used, so I'm pretty sure that's the cause.

Now, note how I had my copy of the WeSay source under /home/munnr/projects, and that directory tree is where the plift2html.xsl and icudt40.dll files could be found. Yet when I look at the traceback, I see that MonoDevelop is looking for the file in /home/munnr/Projects. And if I rename my "Projects" folder to something else like "renamed-Projects", the error goes away entirely.

It's clear what is happening here. Somewhere along the line as MonoDevelop processes the <Link> element, it's trying to create a relative path from the .csproj file to the linked file -- and for some reason, MonoDevelop is going all the way up to my $HOME directory instead of the least common ancestor of the two files (which would lead to the relative paths being "..\Addin.Transform\plift2html.xsl" and "..\..\lib\net2.0\icudt40.dll"). Then along the way, the presence of two directories with case-similar names ("projects" and "Projects") is confusing MonoDevelop, and it's picking the wrong one to read from.

I encountered this bug running MonoDevelop 2.6 Beta 3 (installed via the instructions at http://www.integratedwebsystems.com/2011/05/install-mono-2-10-2-and-monodevelop-2-6-beta-3-on-ubuntu-or-fedora-with-a-bash-script/ on my Ubuntu Natty system). I also tested with the version of MonoDevelop 2.4 packaged with Natty, and the bug occurred in that version as well.
Comment 1 Alan McGovern 2011-12-13 06:28:40 UTC
There were two bugs here. The first of which was we were incorrectly resolving elements using <Link> as a path on the filesystem. The second of which was we were walking all the way down to the root of the filesystem when resolving relative paths even when we shouldn't have be. In this case, as the path started with "../" we should only have walked down one.

I fixed the first issue which will allow MonoDevelop to open this project correctly. The second issue hasn't been dealt with but will not be a problem unless the project files themselves are incorrect/broken. As such, I'll close this bug and open a new one for the latter issue. Thanks for reporting this!