Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder name must be unique in the entire project #246

Closed
enricosada opened this issue Feb 17, 2015 · 12 comments
Closed

Folder name must be unique in the entire project #246

enricosada opened this issue Feb 17, 2015 · 12 comments

Comments

@enricosada
Copy link
Contributor

When multiple folders with the same name ( but different path ) exist in the project, the following error occurs:

The project 'Test.fsproj' could not be opened because opening it would cause a folder to be rendered multiple times in the solution explorer. One such problematic item is 'Second\foo.fs'. To open this project in Visual Studio, first edit the project file and fix the problem.

ref:

an example (see )

<ItemGroup>
    <Compile Include="First\Second\File.fs" />
    <Compile Include="Second\File.fs" />
</ItemGroup>

instead this is ok:

<ItemGroup>
    <Compile Include="First\Second\File.fs" />
    <Compile Include="Third\File.fs" />
</ItemGroup>

also invalid:

<ItemGroup>
    <Compile Include="First\First\File.fs" />
</ItemGroup>

i got a pr to fix this behaviour

@enricosada
Copy link
Contributor Author

btw this check is there to prevent something like this:

<ItemGroup>
    <Compile Include="A\B\File.fs" />
    <Compile Include="C\File.fs" />
    <Compile Include="A\File.fs" />
</ItemGroup>

where folder A is rendered two times, before and after folder C

@SpiegelSoft
Copy link

This is happening now in a Xamarin Android project. It's impossible to work with F# here, because of the requirement to have resources with multiple resolutions.

@SpiegelSoft
Copy link

Visual Studio 2017, V15.6.7

@SpiegelSoft
Copy link

The fix in my case was to put the resource includes above the other files, rather than below. I had copied and pasted a bunch of images into the solution, and the resulting fsproj file looked like this:

<ItemGroup>
    <None Include="Resources\AboutResources.txt" />
    <None Include="Properties\AndroidManifest.xml" />
    <Compile Include="Properties\AssemblyInfo.fs" />
    <Compile Include="MainActivity.fs" />
    <AndroidAsset Include="Assets\AboutAssets.txt" />
    <None Include="GettingStarted.Xamarin" />
    <Content Include="packages.config" />
    <AndroidResource Include="Resources\layout\Main.axml" />
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
  </ItemGroup>

Changing it to this fixed the issue:

<ItemGroup>
    <AndroidResource Include="Resources\layout\Main.axml" />
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
    <None Include="Resources\AboutResources.txt" />
    <None Include="Properties\AndroidManifest.xml" />
    <Compile Include="Properties\AssemblyInfo.fs" />
    <Compile Include="MainActivity.fs" />
    <AndroidAsset Include="Assets\AboutAssets.txt" />
    <None Include="GettingStarted.Xamarin" />
    <Content Include="packages.config" />
  </ItemGroup>

@mfortunat
Copy link

mfortunat commented May 8, 2018

Thanks @SpiegelSoft
it worked perfectly also with VS 2015.
(Version 14.25431.01 Update 3)

@SpiegelSoft
Copy link

This is not fixed. It needs to be reopened.

@SpiegelSoft
Copy link

The fix I posted earlier does not work for my current project.

@SpiegelSoft
Copy link

Thanks Philip. What I have found is this. File order is crucial. If you have more than one file, the ordering needs to be as follows:

    <AndroidResource Include="Resources\mipmap-hdpi\File1.png" />
    <AndroidResource Include="Resources\mipmap-hdpi\File2.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\File1.png" />
    <AndroidResource Include="Resources\mipmap-mdpi\File2.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\File1.png" />
    <AndroidResource Include="Resources\mipmap-xhdpi\File2.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\File1.png" />
    <AndroidResource Include="Resources\mipmap-xxhdpi\File2.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\File1.png" />
    <AndroidResource Include="Resources\mipmap-xxxhdpi\File2.png" />

Any deviation from this ordering will reintroduce the problem.

@cartermp
Copy link
Contributor

@SpiegelSoft I don't quite recall how Android Studio lays Android resources out on disk, but I vaguely recall a similar ordering. Do the Android Xamarin tools not order in the manner by default?

@SpiegelSoft
Copy link

Not using right click with copy and paste.

@SpiegelSoft
Copy link

This is with Visual Studio 2017

@cartermp cartermp added this to the Unknown milestone Jan 30, 2019
@cartermp
Copy link
Contributor

The .NET SDK-style project system fully supports these scenarios:

image

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="First\First\File.fs" />
    <Compile Include="First\Second\File.fs" />
    <Compile Include="Second\File.fs" />
    <Compile Include="Program.fs" />
  </ItemGroup>

</Project>

We're frozen the legacy project system, so I'll close this. Moving code to the .NET SDK project system will resolve any issues of this nature.

@cartermp cartermp removed this from the Unknown / not bug milestone Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants