-
Notifications
You must be signed in to change notification settings - Fork 386
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
File linked to .NET core project gets removed from the project when the BuildAction is set to AdditionalFiles from None. #1149
Comments
@mavasani We added an additional files rule right? Did we also add it to the list of items that show up in the tree (itemSchemas)? @aakash-johari When it disappears, do you mean the solution tree? Or do you mean that it's physically removed from the project file. Can you check the project file and see if it's present? |
@davkean Yes, I verified additional files showed up in solution explorer after changing the build action. Let me attempt to repro @aakash-johari scenario on latest build. |
Yeah, what is the that |
Other content types and item types are here: https://github.com/dotnet/roslyn-project-system/blob/master/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Rules/ProjectItemsSchema.xaml#L61. |
It looks like |
Ok, so I investigated further and this seems unrelated to AdditionalFiles, but is instead specific to linked files.
|
So, I am seeing something weird happening here:
Even clicking save all doesn't change the contents of csproj on the disk, it still has the old item group. |
@davkean Yes the file is removed from the project file and hence no longer visible in the solution tree as well. I have updated the bug description with the .csproj file I used. I opened that project file in visual studio and changed the build action of the abc.xyz to AdditionalFiles. The file abc.xyz disappeared from the solution tree and even the entry from the .csproj file was removed. And if you think that the given .csproj file has the link entry wrong, it has been generated after following code executes in our extension - And the file disappears after we change the type to AdditionalFiles, manually or by following code in our extension - |
@mavasani What's happening with this? Is this our bug or CPS? |
I debugged this further and it looks like a CPS issue. We have correct old and new types inside ProjectItemProviderBase.OnItemIdentityChangedAsync and also invoke SourceItemsProvider_ItemsRemoved for the old item and SourceItemsProvider_ItemsAdded for the new item, but somehow only remove seems to be working and we never add back the new project item. |
I have ported this issue to CPS bug 371345: Changing the BuildAction within VS for a linked file which lies outside the project cone causes the item to disappear from the project file. |
I found the cause in CPS and am working on a fix. However, I found a bigger issue with msbuild: dotnet/msbuild#1598 Items outside the project cone are being matched to globs inside the project cone when using @cdmihai suggested a workaround for now by changing the glob to |
@aakash-johari What's the repro for making a copy of the linked file? |
|
That's not linking a item, that's adding a item. To link, you need to click the arrow next to the Add button and choose "add as link". ie While surprising behavior - that's how it's worked for ~15 years. |
Oh. My bad then. :( I didn't know about "Add as link". Thanks! |
Scenario:
Adding a link from Visual Studio 2017 doesn't seem to be possible. It makes a copy of the file in the project folder. So I edited the .csproj file. In our scenario we don't want to make duplicates of the file.
ConsoleApp1.csproj
The text was updated successfully, but these errors were encountered: