Skip to content

A temp file + 2 folders are left behind in %TEMP% after each dotnet build command #35353

Description

@vkrevs

Describe the bug

Each time dotnet {build|pack|publish|restore|run|test} are run at least 1 new file and 2 folders are left behind in %TEMP% on Windows. On a busy CI system this can very easily result in hundreds of thousands of files in %TEMP% severely degrading disk performance. If that %TEMP% is the default one, then performance of the entire OS is affected. I realize one can/should use an empty temp directory for each test run but nevertheless dotnet should not leave behind orphaned files and folders in %TEMP%.

To Reproduce

Open a command prompt window.
Create a trivial c# console app project:

c:\builds\ConsoleApp1\ConsoleApp1>more ConsoleApp1.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

c:\builds\ConsoleApp1\ConsoleApp1>more Program.cs
Console.WriteLine("Hello, World!");

Set TEMP and TMP environment variables to a newly created empty folder.
Build the project "dotnet build .csproj"
Check the temp folder - it now contains something like

13/09/2023  11:23    <DIR>          92604816-bcee-4952-b2e6-81083d493e5f
13/09/2023  11:23    <DIR>          ba4ceac7-fe82-466a-8512-7f7b2e4f5a90
13/09/2023  11:23               885 Microsoft.NET.Workload_7692_20230913_112323.log

The directories are empty, the file contains something like:

[2023-09-13 11:34:53.120] [00000270] === Logging started ===
[2023-09-13 11:34:53.130] [00000270] Executing: dotnet  build, PID: 624, PPID: 2268
[2023-09-13 11:34:53.135] [00000270] IsElevated: False
[2023-09-13 11:34:53.135] [00000270] Is64BitProcess: True
[2023-09-13 11:34:53.135] [00000270] RebootPending: True
[2023-09-13 11:34:53.135] [00000270] ProcessorArchitecture: amd64
[2023-09-13 11:34:53.135] [00000270] HostArchitecture: x64
[2023-09-13 11:34:53.135] [00000270] SdkDirectory: 7.0.400
[2023-09-13 11:34:53.135] [00000270] VerifySignatures: False
[2023-09-13 11:34:53.135] [00000270] SDK feature band: 7.0.400
[2023-09-13 11:34:54.877] [00000270] Shutting down
[2023-09-13 11:34:54.877] [00000270] Shutdown completed.
[2023-09-13 11:34:54.877] [00000270] Restart required: False
[2023-09-13 11:34:54.878] [00000270] === Logging ended ===

Exceptions (if any)

Further technical details

dotnet --info
.NET SDK:
Version: 7.0.400
Commit: 73bf45718d

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.400\

Host:
Version: 7.0.10
Architecture: x64
Commit: a6dbb800a4

.NET SDKs installed:
2.1.526 [C:\Program Files\dotnet\sdk]
6.0.302 [C:\Program Files\dotnet\sdk]
7.0.306 [C:\Program Files\dotnet\sdk]
7.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions