When compiling, garbage directories are generated.

zequion 451 Reputation points
2024-05-23T02:59:44.3066667+00:00

Directorios

In WinForms and C#, in some projects and not in others, when compiling, some directories and dlls are generated. I don't want the directories to be generated.

I would also like to know if it is possible to not generate the files in the obj directory or at least delete them once compiled.

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,691 Reputation points Microsoft External Staff
    2024-05-23T08:34:01.7133333+00:00

    Hello @zequion,

    You can try to add following line into your project file(.csproj), delete the project cache(bin, obj folders) and rebuild your project to limit the generation of those "language" folders.

    <SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>

    The project file(.csproj) can be opened by right-clicking your project => Unload Project => right-clicking it again => Edit Project File. After you modify the project file, remember to right-click the project again and select Reload Project.

    This line <SatelliteResourceLanguages>en-US</SatelliteResourceLanguages> should be added in <PropertyGroup></PropertyGroup>, for example:

    <PropertyGroup>
      <SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
    </PropertyGroup>
    

    For more details, kindly see this document:

    SatelliteResourceLanguages

    For deleting those .dll files, you can add a post-build event. Right-click your project => Properties => select Build => Events => in "Post-build event" box => type command like del "C:\XXXX\XXXX\*.dll". * is a wildcard character.


    Update1:

    It’s not possible to limit the generation of the obj directory.

    Chaning the output directory to an intermediate/temp directory and delete the temp folder later may be a choice.

    Related document: To set the intermediate output directory for a project(.NET projects)

    and commands:

    `rd /s /q path`, `rmdir /s /q path`
    

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. zequion 451 Reputation points
    2024-05-23T23:36:51.43+00:00

    I have cleaned the directories and now, without adding anything, the fewer directories no longer appear in a project. I have added that line to .csproj and the directories continue to appear in all languages. Also, I don't want to limit it to a language but rather I don't want any directory to be generated.

    Adding code in the post-compile event is useless because I don't want to delete the dlls but rather the directories.


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.