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

Globbing not supported for content in fsproj #5986

Closed
CameronAavik opened this issue Dec 6, 2018 · 5 comments · Fixed by #16817
Closed

Globbing not supported for content in fsproj #5986

CameronAavik opened this issue Dec 6, 2018 · 5 comments · Fixed by #16817
Assignees
Labels
Area-ProjectsAndBuild MSBuild tasks, project files, framework resolution Feature Improvement
Milestone

Comments

@CameronAavik
Copy link
Contributor

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.

@cartermp
Copy link
Contributor

cartermp commented Dec 6, 2018

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.

@cartermp cartermp added this to the 16.0 milestone Dec 6, 2018
@TIHan
Copy link
Contributor

TIHan commented Dec 6, 2018

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

@CameronAavik
Copy link
Contributor Author

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.

@cartermp cartermp modified the milestones: 16.0, 16.1 Feb 21, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, Backlog Apr 30, 2019
@dsyme dsyme added the Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. label Aug 26, 2020
@marner2
Copy link

marner2 commented May 27, 2021

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.

@dsyme dsyme 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 Mar 31, 2022
@dsyme dsyme added Feature Improvement Area-ProjectsAndBuild MSBuild tasks, project files, framework resolution and removed Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-External labels Mar 31, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
@KevinRansom KevinRansom modified the milestones: Backlog, March-2024 Mar 6, 2024
@KevinRansom KevinRansom self-assigned this Mar 6, 2024
@psfinaki
Copy link
Member

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
Labels
Area-ProjectsAndBuild MSBuild tasks, project files, framework resolution Feature Improvement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants