Skip to content

Globbing not supported for content in fsproj #5986

@CameronAavik

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.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions