Skip to content

Build *sporadically* fails with Microsoft.NET.Sdk.StaticWebAssets.Compression.targets: error : IOException: The process cannot access the file (..) because it is being used by another process #62565

Open
@BrunoJuchli

Description

@BrunoJuchli

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Builds on our GH agents sporadically fail with errors like:

C:\Program Files\dotnet\sdk\9.0.301\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(331,5): error : System.IO.IOException: The process cannot access the file '(...)\src\Portal.Web\obj\Release\net9.0\compressed\publish\al7b0not11-v7rodlklwa.br' because it is being used by another process.

Locally I haven't yet been able to reproduce the issue (I'm not saying it can't be reproduced...). On the GH Agent it doesn't fail very often, it looks like less than 5% of the builds.

We have only recently updated from .net 8 to .net 9 (SDK + runtime). Before the update to .net 9, this didn't happen.
I did search for this issue and found similar bug reports, but they were for .net 8, pre-relase versions of .net 9, and one for .net sdk 9.0.100 and closed as fixed over a year ago.
Since we're running 9.0.301 I'm assuming the fix should be included.

Expected Behavior

The build passes.

Steps To Reproduce

You need:

  • .net sdk 9 to compile
  • blazor web assembly project targeting net9.0
  • some static assets

Project Example

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <Nullable>enable</Nullable>
    <InvariantGlobalization>false</InvariantGlobalization>
    <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
    <NullabilityInfoContextSupport>true</NullabilityInfoContextSupport>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.6"/>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all" Version="9.0.6"/>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.6"/>
    <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="9.0.6"/>
    <PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.6"/>
  </ItemGroup>
  
</Project>

Note: due to the sporadic nature of the problem It's hard to really give you a verifiable minimum example. It's possible that the problem only occurs in conjunction with using MudBlazor. So here's a csproj including MudBlazor:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <Nullable>enable</Nullable>
    <InvariantGlobalization>false</InvariantGlobalization>
    <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
    <NullabilityInfoContextSupport>true</NullabilityInfoContextSupport>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.6"/>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all" Version="9.0.6"/>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.6"/>
    <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="9.0.6"/>
    <PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.6"/>
    <PackageReference Include="MudBlazor" Version="8.9.0" />
  </ItemGroup>

  <PropertyGroup>
    <MudAllowedAttributePattern>DataAndAria</MudAllowedAttributePattern>
    <MudIllegalParameters>V7CaseSensitive</MudIllegalParameters>
  </PropertyGroup>

  <ItemGroup>
    <CompilerVisibleProperty Include="MudAllowedAttributePattern" />
    <CompilerVisibleProperty Include="MudIllegalParameters" />
  </ItemGroup>
  
</Project>

Exceptions (if any)

System.IO.IOException: The process cannot access the file 'D:\a\smartme-cloud\smartme-cloud\src\Portal.Web\obj\Release\net9.0\compressed\publish\al7b0not11-v7rodlklwa.br' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.IO.FileInfo.OpenRead()
at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.ComputeFingerprintAndIntegrity(FileInfo fileInfo)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets.Execute()

.NET Version

.net sdk 9.0.301
.net 9.0.6

Anything else?

dotnet --info

.NET SDK:
Version: 9.0.301
Commit: a596cd22e2
Workload version: 9.0.300-manifests.9bcbba73
MSBuild version: 17.14.5+edd3bbf37

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.301\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.6
Architecture: x64
Commit: 3875b54e7b

.NET SDKs installed:
8.0.117 [C:\Program Files\dotnet\sdk]
8.0.314 [C:\Program Files\dotnet\sdk]
8.0.411 [C:\Program Files\dotnet\sdk]
9.0.107 [C:\Program Files\dotnet\sdk]
9.0.205 [C:\Program Files\dotnet\sdk]
9.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.6 [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:
D:\Development\smartme-cloud2\global.json

Contents of global.json

{
  "sdk": {
    "version": "9.0.301",
    "rollForward": "disable"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions