Programing

TFS 소스 제어에서 특정 파일을 제외하는 방법

crosscheck 2020. 9. 9. 07:31
반응형

TFS 소스 제어에서 특정 파일을 제외하는 방법


여러 구성 파일 (app.DEV.config, app.TEST.config 등)과 올바른 구성 파일을 app.config에 복사하는 사전 빌드 이벤트가 있습니다. 분명히 구성 특정 파일은 소스 제어에 있지만 현재 App.Config도 마찬가지입니다.

한 파일을 소스 제어에서 제외되었지만 분명히 프로젝트에서 제외 된 것으로 표시하려면 어떻게해야합니까?

VS 2005 및 2005 Team Explorer를 사용하고 있습니다.


MS Power Tools에는 정규식에 대해 파일 이름을 선별 할 수있는 체크인 정책 (금지 된 패턴 정책)이 있습니다. 참조 : Microsoft Team Foundation Server Power Tools

체크인 정책이 완전히 안전하지는 않지만 TFS가 찾고있는 것과 같은 사용자 정의 규칙을 적용하는 데 가장 가까운 것입니다.

(다른 사람들이 말했듯이 파일이나 폴더를 은폐 할 수도 있습니다. 즉, 소스 제어에 유지되고 팀의 다른 모든 사람이 볼 수 있지만 은폐를 해제하기 전에는 PC에 복사되지 않습니다. 파일을 삭제할 수 있습니다. 즉, 모든 사람의 PC에서 최신 버전이 나올 때 삭제됩니다. 그러나 이러한 옵션 중 어느 것도 이러한 파일이 처음에 소스 제어에 추가되는 것을 방지하지 못합니다.)


TFS2012에서는 .tfignore 파일을 만드는 것이 쉽습니다.

http://msdn.microsoft.com/en-us/library/tfs/ms245454%28v=vs.110%29.aspx#tfignore

######################################
# Ignore .cpp files in the ProjA sub-folder and all its subfolders
ProjA\*.cpp
# 
# Ignore .txt files in this folder 
\*.txt
#
# Ignore .xml files in this folder and all its sub-folders
*.xml
#
# Ignore all files in the Temp sub-folder
\Temp
#
# Do not ignore .dll files in this folder nor in any of its sub-folders
!*.dll

# EDIT https://msdn.microsoft.com/en-us/library/ms245454(v=vs.110).aspx#tfignore
# A filespec is recursive unless prefixed by the \ character.

솔루션 탐색기에서 App.config 파일을 선택하고 파일-> 소스 제어-> 소스 제어에서 App.config 제외를 선택합니다.


찾기 어려운 옵션이 있습니다.

1. 솔루션 탐색기에서 파일 또는 여러 파일 선택

2. 파일-> 소스 제어-> 고급으로 이동합니다.

제외 할 경로

그리고 여기 있습니다

다음은 제외입니다.

Keep in mind: If you right click a file in Solution Explorer you only find "the most important options" not all :)


If all you want is to have a file in the project but not under source control with TFS, just go into SourceControl, delete the said file, and undo your checkout of the project file (it will attempt to remove the file from the project as well). Then check-in your delete of the file you are excluding. In the solution explorer you should see that there is no source control icon next to the file you're excluding. The project file should list a file there, but that file should now no longer be under source control.

Keep in mind, any other person will now see a missing file in the project when they get latest.


TFS allows you to cloak at the folder/file level. When something is cloaked, TFS won't attempt to sync it (much like a svn:ignore).

When setting up your workspace, cloak anything you want TFS to ignore. A more detailed how-to is here.


This worked for me:

One way is to add a new or existing item to a project (e.g. right click on project, Add Existing Item or drag and drop from Windows explorer into the solution explorer), let TFS process the file(s) or folder, then undo pending changes on the item(s). TFS will unmark them as having a pending add change, and the files will sit quietly in the project and stay out of TFS.

Source: =">How can I exclude a specific files from TFS source control


Visual Studio 2013 (and 2012)

This feature is available by selecting the file(s) and going to:

File > Source Control > Advanced > Exclude ... from Source Control

This question was asked a while ago but it pertains to the same type of issue I was having.

The Problem:

  • We want to check in our code.
  • We then want build our project.
    • During our build we depend on Build Events to move files around so we have the proper files in place for the build process to complete.
  • When our Build Event tries to copy the files, we get Access Denied errors.

The Reason:

  • Team Foundation Server Visual Studio Plugin changes the Read Only attribute on our files to READONLY TRUE when we check in our files.

Build Event Example:

  • copy "$(TargetDir)SomeFile.ext" "$(ProjectDir)"

Above, we simply need to move a file from our Target Build Path (the bin\debug or bin\release folders) to our Project Folder. In my situation, this was so I could include project built files in my installer. My Installer wasn't grabbing them as part of the Project Output.

The Fix: (nearly kicked my self in the face when I figured this out)

New Build Event:

  • attrib -R "$(ProjectDir)SomeFile.ext"
  • copy "$(TargetDir)SomeFile.ext" "$(ProjectDir)"
  • attrib +R "$(ProjectDir)SomeFile.ext"

We're all having fun with Build Events right? Above I simply do 2 things, I remove the read only attribute, now the files not read only. Copy my file as I was originally wanting to. Then replace the Read Only Attribute (optional I guess) to keep Visual Studio and Team Foundations happy.

And yes... I'm still kicking myself in the face on this one.


I have a similar issue, my App.config contained sensible data (e.g. username) that this data should not by sync with TFS.

The article Best practices for deploying passwords and other sensitive data to ASP.NET and Azure App Service describes an good approach to prevent this issue:

Use the "file" attribute of the "appSettings" element to reference an config file that is not added to source-control


If you have an older version than TFS2012 and thus can't create a .tfignore file or use the File > Source Control > Advanced > Exclude … option, you can try this:

  • Make a copy of the target file in Windows Explorer.
  • Undo Pending Changes (if any) on the target file in Team Explorer/Visual Studio.
  • Delete the target file in Windows Explorer.
  • 대상 파일의 복사본을 삭제 된 대상 파일의 위치로 이동하고 삭제 된 대상 파일과 동일한 이름을 갖도록 이름을 바꿉니다.

TFS는 이제 대상 파일의 변경 사항을 무시하는 것 같습니다. 파일을 다시 편집해야하는 경우 Visual Studio를 사용하지 마십시오. 그러면 TFS가 파일을 보류중인 변경 사항이있는 파일 목록에 다시 넣습니다.

참고 URL : https://stackoverflow.com/questions/1369442/how-can-i-exclude-a-specific-file-from-tfs-source-control

반응형