I have a large solution in which the "root" project includes feature projects by glob:
<ProjectReference Include="..\Feature\*\*.csproj" />
This works, despite not looking great in the references list, but the issue that occasionally Visual Studio will rewrite the csproj with all of the project references resolved:
<ProjectReference Include="..\Feature\A\A.csproj" />
<ProjectReference Include="..\Feature\B\B.csproj" />
It's not clear what triggers this, but I'm guessing it might have something to do with NuGet.
Is there anyway to stop VS from doing this (akin to using DisableFastUpToDateCheck
for custom MSBuild scenarios)?
I've done further research on this.
For testing, you can consistency reproduce the expansion by renaming any project that's included in the wildcard pattern.
Also, the easiest way to prevent the expansion is to:
Directory.Build.props
or another external fileDisableFastUpToDateCheck
totrue
in your csprojUsing properties doesn't work and isn't required, likewise with using an
Exclude
.It should be related to the items in the
ItemGroup
. I have the similar issue before, but the difference is that I use wildcards to contain.cs
files and your are.csproj
files, looks like:When I delete one of
.cs
file in the<ItemGroup>
, the wildcard gets expanded in the csproj file. For you case, if I deleted the the C.csproj project from Visual Studio (Add it before, reload the root project), then I got the same result as you.For this issue, many other community members submit a user voice to Visual Studio team: VS IDE should support file patterns in project files. Now this is well supported in the new project system used by
.NET Core
and.NET Standard
in Visual Studio 2017, but they haven't done the work to support it for existing project types.To resolve this issue, you can use option
Exclude="..."
to exclude the project that you do not want to refer to:Or, if you want to delete one of project and keep the wildcard pattern, you only need to unload the root project, then delete the reference project, reload the root project, the wildcard pattern would be preserved.
Hope this helps.