让 TFS 忽略我的包文件夹 [英] Get TFS to ignore my packages folder

查看:41
本文介绍了让 TFS 忽略我的包文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让 TFS (2013) 忽略我的 packages 文件夹.我非常不希望它在源代码上受到控制,因为我正在使用 NuGet,它很棒!

I'm trying to get TFS (2013) to ignore my packages folder. I passionately don't want it source controlled as I'm using NuGet and it's great!

我尝试隐藏(似乎不起作用),我尝试添加 .tfignore 文件 - 没有任何内容被忽略.为什么 TFS 团队不像许多 Subversion 客户端那样添加一个永久忽略文件夹或文件的选项?!

I've tried cloaking (doesn't seem to work), I've tried adding .tfignore files - nothing is ignored. Why don't the TFS team just add an option to permanently ignore a folder or file like lots of the Subversion clients do?!

推荐答案

事情是这样的:我们必须告诉 NuGet TFS 忽略包,因为 NuGet 正在尝试进行源代码控制绝对不应该做的相关事情(糟糕的形式,微软!).所以你必须做两件事.

Here's the deal: We have to tell both NuGet and TFS to ignore the packages, because NuGet is trying to do source-control related stuff that it absolutely shouldn't be doing (bad form, Microsoft!). So you have to do two things.

首先,在解决方案文件夹中添加一个名为.tfignore的文件(注意tf后面缺少s).其内容应如下:

First, add a file named .tfignore to the solution folder (note the lack of s after the tf). Its contents should be as follows:

\packages

这告诉 TFS 忽略您的包文件夹.现在,您会认为这也会忽略 repositories.config 文件.但不会.为什么?谁知道呢,微软的方式既奇特又神秘.实际上,我认为它是我在下面概述的 NuGet 内容的一部分,但是如果将来修复它并且您想保留 repositories.config 文件而不是让 VS 重新生成它,您应该能够使用这个:

That tells TFS to ignore your packages folder. Now, you would think that this would also ignore the repositories.config file. But it won't. Why? Who knows, the ways of Microsoft are strange and mysterious. Actually, I think it's part of the NuGet stuff I outline below, but if that ever gets fixed in the future and you want to keep the repositories.config file instead of letting VS regenerate it, you should be able to use this:

\packages
!\packages\repositories.config

好的,现在多亏了我们的 .tfignore 文件,TFS 将忽略您的包.一切都很好,对吧?错误,因为 NuGet 正在处理您的源代码管理并将包添加到您的待处理更改中.所以现在让我们告诉 NuGet 把它剪掉.

OK, so now thanks to our .tfignore file, TFS is ignoring your packages. Everything is fine, right? WRONG, because NuGet is mucking around with your source control and adding the packages to your pending changes. So now let's tell NuGet to cut it out already.

在解决方案文件夹的根目录中创建一个名为 .nuget 的文件夹.1 现在,创建一个名为 NuGet.config 的文件,然后把它放在这个新文件夹2.其内容应如下所示:

Create a folder called .nuget in the root of your solution folder.1 Now, create a file called NuGet.config, and put it in this new folder2. Its contents should look like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
</configuration>

并且现在您的包应该不受源代码控制.只需记住将 NuGet.config.tfignore 文件添加到源代码管理中,这样它们就不会丢失.

And now your packages should stay out of source control. Just remember to add the NuGet.config and .tfignore files to source control so they never get lost.

如果您遇到问题,您可能需要删除您的包文件夹,签入该更改,然后执行上述步骤.

If you're having issues, you may want to delete your packages folder, check in that change, and then go through the steps above.

新版本的 Nuget 似乎不会发生这种情况.因此,如果您切换到 VS/TFS 2017,这个问题可能会解决,而无需跳过上述问题.

ALSO It looks like this won't happen with newer versions of Nuget. So maybe if you switch to VS/TFS 2017 this issue will clear up without jumping through the above hoops.

1.使用 Source Control Explorer 添加文件夹;右键解决方案->添加文件夹->.nuget
2.当我使用 VS 2013 发现这一点时,我发现 NuGet.config 必须放在 .nuget 文件夹中.即使您的解决方案文件夹的根目录中已经有一个 NuGet.config 文件(例如,因为您的公司有一个内部 nuget 提要).但是,评论中有些人表示它在VS 2015中的解决方案根目录中运行良好. 个人而言,我在git模式下切换到使用TFS,因此无法测试.此外,如果您确实有自定义提要,请确保您将自定义提要和 nuget.org 作为 Nuget.config 文件中的键,否则有时 TFS 会随机决定它无法恢复包.

1. Add the folder using Source Control Explorer; right-click the solution->Add folder->.nuget
2. When I figured this out using VS 2013, I found the NuGet.config had to go in the .nuget folder. Even if you already have a NuGet.config file in the root of your solution folder (because, say, your company has an internal nuget feed). However, some in the comments have indicated that it works fine in the solution root in VS 2015. Personally, I switched to using TFS in git mode, so I can't test. Additionally, if you do have a custom feed, ensure that you have both the custom feed and nuget.org as keys in the Nuget.config file, or sometimes TFS will randomly decide it can't restore the packages.

这篇关于让 TFS 忽略我的包文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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