Skip to content

Globbing not supported for content in fsproj #5986

Description

@CameronAavik

Repro steps

  1. Create new F# Console App (.NET Core) Project in Visual Studio
  2. Using the solution explorer, add a new folder in the project called "data"
  3. Then add a new file to that folder called "data.txt"
  4. Unload and modify the .fsproj file so that the following line:
<Content Include="data\data.txt" />

is replaced with:

<Content Include="data\*.txt" />
  1. Reload the project and try add a new file to the data directory

Alternative repro steps

  1. Clone my repo
  2. Open the .sln in Visual Studio
  3. Try add a new file to the input_files/2017 directory.

Expected behavior

The new file gets added to the project, but does not cause any modifications to the .fsproj file as it is already covered by the Content Include

Actual behavior

A recoverable exception is thrown causing the data folder to disappear from the project including the removal of the Content Include from the fsproj file. The stacktrace of the exception is as follows:

=====================
6/12/2018 7:50:56 PM
Recoverable
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The reference node is not a child of this node.
   at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args)
   at Microsoft.Build.Construction.ProjectElementContainer.VerifyForInsertBeforeAfterFirst(ProjectElement child, ProjectElement reference)
   at Microsoft.Build.Construction.ProjectElementContainer.InsertBeforeChild(ProjectElement child, ProjectElement reference)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderingHelper.TryMoveElements(ImmutableArray`1 elements, ProjectItemElement referenceElement, MoveAction moveAction)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderingHelper.TryMoveElementsToTop(Project project, ImmutableArray`1 elements, IProjectTree target)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderingHelper.<>c__DisplayClass0_0.<Move>b__0(Project project)
   at Microsoft.VisualStudio.ProjectSystem.ProjectAccessor.<OpenProjectForWriteAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderAddItemHintReceiver.<HintedAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Designers.ProjectChangeHintSubmissionService.<>c__DisplayClass42_0.<<ProjectLockService_ReleasedWriteLockAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The reference node is not a child of this node.
   at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args)
   at Microsoft.Build.Construction.ProjectElementContainer.VerifyForInsertBeforeAfterFirst(ProjectElement child, ProjectElement reference)
   at Microsoft.Build.Construction.ProjectElementContainer.InsertBeforeChild(ProjectElement child, ProjectElement reference)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderingHelper.TryMoveElements(ImmutableArray`1 elements, ProjectItemElement referenceElement, MoveAction moveAction)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderingHelper.TryMoveElementsToTop(Project project, ImmutableArray`1 elements, IProjectTree target)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderingHelper.<>c__DisplayClass0_0.<Move>b__0(Project project)
   at Microsoft.VisualStudio.ProjectSystem.ProjectAccessor.<OpenProjectForWriteAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.VS.Input.Commands.Ordering.OrderAddItemHintReceiver.<HintedAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Designers.ProjectChangeHintSubmissionService.<>c__DisplayClass42_0.<<ProjectLockService_ReleasedWriteLockAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )<---

===================

Known workarounds

I am able to resolve this by unloading the .fsproj file, readding the removed line, and loading again. Doing this shows the data folder with the original file and the file I attempted to create

Related information

  • Operating system: Windows 17134.407
  • Visual Studio: 15.9.3
  • Visual F# Tools 10.2 for F# 4.5: 15.8.0.0. Commit Hash: 6e26c5b
  • .NET Core 2.2

Note: I attempted to recreate this issue on a C# solution but wasn't able to since C# projects do not require a Content Include to be added to the .csproj file for the directory to be included in the project.

Activity

  1. cartermp commented on Dec 6, 2018

    @cartermp
    Contributor

    Thanks @CameronAavik, this is related to file ordering. Looks like you've hit an edge case where you want to partially glob non-F# items under a specific folder. Not sure what the state of the world ought to be for F#, but @TIHan would know more.

  2. added this to the 16.0 milestone on Dec 6, 2018
  3. TIHan commented on Dec 6, 2018

    @TIHan
    Contributor

    The current state of the world is that we do not support globbing. However, I believe we should not be throwing an error.

    If it is possible, it wouldn't be a bad idea to design globbing for files that are not important for file ordering and figure out how its interaction plays into file ordering

  4. CameronAavik commented on Dec 7, 2018

    @CameronAavik
    ContributorAuthor

    Yeah that makes sense for F# files. In my case I wish to use it as I have a number of resources in a directory that I want to have automatically copied to the output directory. I was hoping to make it so that if I add a new resource I don't have to add a new rule in to copy it to output every time. I can of course manually do that each time, but having it supported would be nice.

  5. modified the milestones: 16.0, 16.1 on Feb 21, 2019
  6. modified the milestones: 16.1, 16.2 on Apr 23, 2019
  7. modified the milestones: 16.2, Backlog on Apr 30, 2019
  8. added
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    on Aug 26, 2020
  9. 2 remaining items

  10. marner2 commented on May 27, 2021

    @marner2

    Are there any updates on this? We're running into this issue as well with resource files that we want tracked with the project. This forces us to use another IDE (vscode) to manage those resources.

  11. changed the title [-]Content Include removed from fsproj file after adding file to folder using VS Solution Explorer[/-] [+]Globbing not supported for content in fsproj[/+] on Mar 31, 2022
  12. added
    Area-ProjectsAndBuildMSBuild tasks, project files, framework resolution
    and removed
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    on Mar 31, 2022
  13. modified the milestones: Backlog, March-2024 on Mar 6, 2024
  14. self-assigned this
    on Mar 6, 2024
  15. psfinaki commented on Mar 27, 2024

    @psfinaki
    Contributor

    The respective fix was reverted, see the comment here. This is essentially won't/can't fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions