Nuget DisableSourceControlIntegration 不工作
Nuget DisableSourceControlIntegration not working
我在使用 NuGet 时尝试遵循不提交策略,使程序集远离 TFS。我希望项目自动恢复依赖关系,而不是向 TFS 添加挂起的更改。
我已经阅读了一些方法来做到这一点;一个正在使用 .tfignore,这将是我们拥有的项目数量的一个痛苦。我们可以隐藏 TFS 中的文件夹,但我们需要为每个项目添加 packages 文件夹才能隐藏它。最后一种方法是使用 disableSourceControlIntegration 通过 NuGet.config 配置 NuGet,这将阻止 NugetClient 将包添加到项目或解决方案。
**这是配置 XML 我正在使用:
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
如果我将它放在我的 {SolutionDir}.nuget 文件夹中,它适用于该解决方案。我试图将它放在我的 %AppData%\nuget 文件夹中,以便它应用于所有解决方案,但包还原仍然导致 TFS 添加我的包文件夹内容。
我正在使用 Visual Studio 2013、NuGet 2.8.6 和来自 VSOnline 的 TFS。**
我认为没有办法将此密钥放在根位置,看起来 Nuget 仅在 {SolutionDir}.nuget 文件夹中指定时才接受该密钥。 Nuget 文档明确提到此密钥在解决方案级别工作,需要添加到 {SolutionDir}.nuget 文件夹。
Source Control Integration
"disableSourceControlIntegration" under section "solution" allows you to disable source control integration for the "Packages" folder. This key works at the solution level and hence need to be added in a NuGet.config file in the "$(SolutionDir).nuget directory". The default value for this key is true.
编辑和更新:感谢@TonyStewart871 找到此信息。我没有在 3.2 版本中测试过,也找不到官方文档。
但根据此 GITHUB LINK Comments Section,从 NuGet 版本 3.2 开始,可以在用户级别为 %appdata%\nuget\nuget.config 中的所有解决方案添加密钥 "disableSourceControlIntegration"文件,而不是在单个解决方案级别添加。请在下面找到 deepakaravindr 的评论:
"You can add the setting not just to the solution level nuget.config, but also to your nuget.config at %appdata%\nuget. That works too! Just that it will get applied to every solution that you open on that machine. Remember to add the following section as a child to < configuration > section. And, note that the setting should always be under the < solution > section for it to work"
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
有一个 DisableSourceControlIntegration-TFS NuGet 包,它将 {SolutionDir}.nuget 文件夹和配置文件添加到解决方案,以及 NuGet 包文件夹的 .tfignore 文件。它甚至比手动添加单个配置文件更容易。您可以在这里找到它:https://www.nuget.org/packages/DisableSourceControlIntegration-TFS.
相对于单个 TFS 项目,允许排除 NuGet 包文件夹的策略是正确的,因为仅当您需要从多个开发人员访问公共项目存储库时,排除 nuget 包才有意义。
因此,如果任何人需要在他的本地机器上复制解决方案的结构,第一次只恢复 NuGet 包(及其内容(库)),可以做到这一点,而不会出现与兼容性库等相关的任何问题。 .
每次 NuGet 恢复 Packages 文件夹中的库并且解决方案编译良好。
虽然,如果你只应该配置 NuGet 行为,其他开发人员也应该这样做,因此它应该错过这个配置策略的便利:任何人都应该每次都在他的本地机器上复制这个配置规则..
相反,将此规则及其解决方案存储在 tfs 中允许每个人继承此规则。
或者,如果一个人想单独处理一个项目,他可以避免如果他想配置 NuGet 不提交其 "Packages" 文件夹内容,那么存储这个特定 NuGet 规则的策略在 TFS 中是一个不错的选择。
我在使用 NuGet 时尝试遵循不提交策略,使程序集远离 TFS。我希望项目自动恢复依赖关系,而不是向 TFS 添加挂起的更改。
我已经阅读了一些方法来做到这一点;一个正在使用 .tfignore,这将是我们拥有的项目数量的一个痛苦。我们可以隐藏 TFS 中的文件夹,但我们需要为每个项目添加 packages 文件夹才能隐藏它。最后一种方法是使用 disableSourceControlIntegration 通过 NuGet.config 配置 NuGet,这将阻止 NugetClient 将包添加到项目或解决方案。
**这是配置 XML 我正在使用:
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
如果我将它放在我的 {SolutionDir}.nuget 文件夹中,它适用于该解决方案。我试图将它放在我的 %AppData%\nuget 文件夹中,以便它应用于所有解决方案,但包还原仍然导致 TFS 添加我的包文件夹内容。
我正在使用 Visual Studio 2013、NuGet 2.8.6 和来自 VSOnline 的 TFS。**
我认为没有办法将此密钥放在根位置,看起来 Nuget 仅在 {SolutionDir}.nuget 文件夹中指定时才接受该密钥。 Nuget 文档明确提到此密钥在解决方案级别工作,需要添加到 {SolutionDir}.nuget 文件夹。
Source Control Integration "disableSourceControlIntegration" under section "solution" allows you to disable source control integration for the "Packages" folder. This key works at the solution level and hence need to be added in a NuGet.config file in the "$(SolutionDir).nuget directory". The default value for this key is true.
编辑和更新:感谢@TonyStewart871 找到此信息。我没有在 3.2 版本中测试过,也找不到官方文档。
但根据此 GITHUB LINK Comments Section,从 NuGet 版本 3.2 开始,可以在用户级别为 %appdata%\nuget\nuget.config 中的所有解决方案添加密钥 "disableSourceControlIntegration"文件,而不是在单个解决方案级别添加。请在下面找到 deepakaravindr 的评论:
"You can add the setting not just to the solution level nuget.config, but also to your nuget.config at %appdata%\nuget. That works too! Just that it will get applied to every solution that you open on that machine. Remember to add the following section as a child to < configuration > section. And, note that the setting should always be under the < solution > section for it to work"
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
有一个 DisableSourceControlIntegration-TFS NuGet 包,它将 {SolutionDir}.nuget 文件夹和配置文件添加到解决方案,以及 NuGet 包文件夹的 .tfignore 文件。它甚至比手动添加单个配置文件更容易。您可以在这里找到它:https://www.nuget.org/packages/DisableSourceControlIntegration-TFS.
相对于单个 TFS 项目,允许排除 NuGet 包文件夹的策略是正确的,因为仅当您需要从多个开发人员访问公共项目存储库时,排除 nuget 包才有意义。
因此,如果任何人需要在他的本地机器上复制解决方案的结构,第一次只恢复 NuGet 包(及其内容(库)),可以做到这一点,而不会出现与兼容性库等相关的任何问题。 .
每次 NuGet 恢复 Packages 文件夹中的库并且解决方案编译良好。
虽然,如果你只应该配置 NuGet 行为,其他开发人员也应该这样做,因此它应该错过这个配置策略的便利:任何人都应该每次都在他的本地机器上复制这个配置规则..
相反,将此规则及其解决方案存储在 tfs 中允许每个人继承此规则。
或者,如果一个人想单独处理一个项目,他可以避免如果他想配置 NuGet 不提交其 "Packages" 文件夹内容,那么存储这个特定 NuGet 规则的策略在 TFS 中是一个不错的选择。