Visual Studio 2022- File Ignored always ignore when adding to class librarar

Dani_S 4,836 Reputation points
2025-12-11T17:39:46.8933333+00:00

Hi,

Please see the following screenshot, why adding a new new file I always need to

use Git/Add ignore file (right click on the file) ?

It happened in class library as follow: TargetFramework>netstandard2.0</TargetFramework>

Thanks in advance,

User's image

Developer technologies | Visual Studio | Extensions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 1,205 Reputation points Microsoft External Staff
    2025-12-12T12:19:23.12+00:00

    Thanks for reaching out!

    Here are some steps to fix the issue

    1. Check Your .gitignore File: Make sure you don't have patterns in your .gitignore file that are matching the new files you are trying to add. You can find this file in your project's root directory. If it's not there, maybe create one to customize which files should be ignored
    2. Create or Modify the .tfignore File: If you are using Team Foundation Version Control (TFVC), you can also utilize a .tfignore file. This file works similarly to .gitignore. Place it in your project directory to specify which files should be ignored by source control.
    3. Check Local Workspace Settings: In some cases, certain file types might be automatically excluded based on your workspace settings. Review the settings to ensure your new files' types are not inadvertently excluded.
    4. Visual Studio Integration: If it's a specific file type that you want to work with and you've previously ignored it, you can right-click on the file in the Git Changes window and select Ignore this local item to update your .gitignore file accordingly. This will help in managing ignored files more effectively.
    5. Keep It Updated: Ensure your installed packages and updates to Visual Studio are current. Bugs are often fixed in newer updates that may address your issue.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.