Modernize Shared Projects: Use globs in projitems files, allow editing them in VS
See original GitHub issueVisual Studio Version: 16.6
Expected Behavior:
- Newly created projitems files contain a single line.
<Compile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
-
IDE does not add new entries to the file when adding files to the shared project that uses globs.
-
IDE does not change projitems file when a file is removed using Solution Explorer UI
-
IDE does not change projitems files when a file is moved from one shared project to another
-
The IDE can open projitems file for editing
Actual Behavior:
-
Newly created shared project’s projitems file does not have the glob include.
-
Adding a new file in the IDE to a shared project that contains entry with a glob adds an explicit entry.
-
Removing the file in IDE removes the item glob and breaks the project.
-
Moving files between shared projects removes the item glob from source project and breaks the project.
-
Can’t open projitems file for editing in VS.
-
Cannot use Build Current Project
Scenarios
-
Merge conflicts
Listing all items in the projitems file results in frequent merge conflicts that need to be resolved.
-
Slow project reloading
Changing a branch to one where the project contains different files leads to project reloading.
-
Keeping the list of files in sync with the actual directory content adds maintenance cost
-
Adding a link to an existing file to a shared project.
Because “add a link to an existing file” feature is not available, one needs to edit the projitems file manually. Due to [5] that’s also not possible in VS. The file needs to be open and edited in an external editor. Once the linked
<Compile>
item is added and the file is saved the VS reloads the project. One needs to also make sure that any unsaved changes in the file made by VS were saved, otherwise they would be discarded.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:9 (8 by maintainers)
@jjmew can items like ‘6: Cannot use Build Current Project’ be done? We should already know the current project context (since we present it in things like the nav bar list):
So it feels like it should be hard for build-current-project to support that. Note: because i don’t have build-current-project, my only option is to build-all. But this takes around 25 minutes on my box. So this is really incredibly painful to deal with.
I’m not sure the level of pain is truly understood 😃
Also:
Just does not seem to work at all. So, effectively, shared files feel like random floating files that i never know how to find or deal with.
@tmat I’m testing this workaround : instead of a .shproj, use a .csproj for the shared project.
Prevent the shared project from being compiled by editing its .csproj like below. This will still automatically include all files in the project’s folder to be part of the project from the Solution Explorer’s point of view, as well as for source control.
To reference the shared project files, do this:
As far has I have tested, it gives you all features from your expected behavior.