I am using Visual Studio 2019 for my C# based solution and I use Git for source control. Yesterday I added two new .NET 2.0 standard SDK projects to my solution and for some reason VS keeps showing the bin
folder in the solution explorer for these projects. They have a red icon on them. Does anyone know what that means and how can I get rid of them?
Visual Studio keeps showing the bin folder in my project
Asked Answered
I realized the cause of this behavior. It is because I am excluding the output of the project compilation to be included in the nuget package because these are analyzer projects.
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
I recently noticed this too, and ended up here searching for answers. So is this just the way it is? If you're working on an analyzer, you see the bin folder? Or did you ever discover some way to hide it? –
Coolth
I think @Pharaz should be the accepted answer now as that resolves it. –
Siliceous
You can use TfmSpecificPackageFile
instead of <None Include...
. This is what the analyzer template of Visual Studio generates and by using it, the bin
folder won't be shown in the solution explorer.
<PropertyGroup>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>
<Target Name="_AddAnalyzersToOutput">
<ItemGroup>
<TfmSpecificPackageFile Include="$(OutputPath)\$(AssemblyName).dll" PackagePath="analyzers/dotnet/cs" />
</ItemGroup>
</Target>
Worked for me. If your project is multi targeted you will need to limit the item group to a specific target to avoid multiple copies of the dll to analyzers/dotnet/cs which errors. –
Siliceous
© 2022 - 2024 — McMap. All rights reserved.
git status
)? – Anomalismgit status
in the project folder, it does not show the bin folder in the output. May be I accidentally did something that is causing it. BTW, the .gitignore already has all bin folders excluded. How else can I check what is causing this item to show up in VS Solution explorer or its status in git? – Bibliofilm.gitignore
file(s). They should only excludebin
, not any subfolder of it. – Anomalism<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
– Bibliofilm