防止Visual Studio重写项目引用 [英] Preventing Visual Studio from rewriting project references
问题描述
我有一个大型解决方案,其中根"项目包括glob的要素项目:
I have a large solution in which the "root" project includes feature projects by glob:
<ProjectReference Include="..\Feature\*\*.csproj" />
尽管在引用列表中看起来并不好,但这仍然可行,但是偶尔 Visual Studio会在解决所有项目引用的情况下重写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" />
目前尚不清楚是什么触发了这一点,但我猜想它可能与NuGet有关.
It's not clear what triggers this, but I'm guessing it might have something to do with NuGet.
是否有阻止VS执行此操作的方法(类似于将DisableFastUpToDateCheck
用于自定义MSBuild方案)?
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
或其他外部文件 - 在csproj中将
DisableFastUpToDateCheck
设置为true
- Move the project reference globs into
Directory.Build.props
or another external file - Set
DisableFastUpToDateCheck
totrue
in your csproj
使用属性既无效也不是必需的,就像使用Exclude
一样.
Using properties doesn't work and isn't required, likewise with using an Exclude
.
这篇关于防止Visual Studio重写项目引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!