防止Visual Studio重写项目引用 [英] Preventing Visual Studio from rewriting project references

查看:96
本文介绍了防止Visual Studio重写项目引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型解决方案,其中根"项目包括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:

  1. 将项目引用文件移至Directory.Build.props或其他外部文件
  2. 在csproj中将DisableFastUpToDateCheck设置为true
  1. Move the project reference globs into Directory.Build.props or another external file
  2. Set DisableFastUpToDateCheck to true in your csproj

使用属性既无效也不是必需的,就像使用Exclude一样.

Using properties doesn't work and isn't required, likewise with using an Exclude.

这篇关于防止Visual Studio重写项目引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆