dotnet / dotnet/aspnetcore

Microsoft.AspNetCore.Mvc.Testing 6.0.0 has concurrency issues on filesystem

Open
#38,808 7 comments 14 reactions 0 assignees View on GitHub
area-minimal area-mvc feature-mvc-testing investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Describe the bug
After Upgrading to Microsoft.AspNetCore.Mvc.Testing 6.0.0 we are encountering concurrency issus on dotnet publish tasks.
Below you find a minimal repo to reproduce the issue. The setup is following. We have a testhelper project that references the Microsoft.AspNetCore.Mvc.Testing 6.0.0 Nuget. Two projects referencing the testhelpers. So the two testprojects have implicit references to Microsoft.AspNetCore.Mvc.Testing. On publish the following issue seen under Exceptions.
The issue is not persistant and happens only in some cases. Around 25 % of the publishes. So the minimal repo contains a runner script that loops over the given buildsteps in a Dockerfile.

### To Reproduce
Prerequisites: Docker and Shell

Clone Repo https://github.com/lippinio/concurrency
chmod +x runner.sh
Run runner.sh

### Exception

> ` > [6/6] RUN dotnet publish ./concurrency.sln --configuration Release --no-build --output ./out:
#10 0.504 Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
#10 0.504 Copyright (C) Microsoft Corporation. All rights reserved.
#10 0.504
#10 1.439 testhelpers -> /app/out/
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: The "GenerateMvcTestManifestTask" task failed unexpectedly. [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: System.IO.IOException: The process cannot access the file '/app/out/MvcTestingAppManifest.json' because it is being used by another process. [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: at Microsoft.Win32.SafeHandles.SafeFileHandle.Init(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: at Microsoft.AspNetCore.Mvc.Testing.Tasks.GenerateMvcTestManifestTask.Execute() [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/app/tests1/tests1.csproj]
#10 1.854 /root/.nuget/packages/microsoft.aspnetcore.mvc.testing/6.0.0/build/net6.0/Microsoft.AspNetCore.Mvc.Testing.targets(57,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/app/tests1/tests1.csproj]
`

Contributor guide

Open the contributing guide

Research direction

Start with runner.sh and the Dockerfile in the linked reproduction, then inspect the Microsoft.AspNetCore.Mvc.Testing.targets entry at line 57 and the GenerateMvcTestManifestTask named in the exception. Repeatedly run dotnet publish ./concurrency.sln --configuration Release --no-build --output ./out; done means concurrent publishes no longer fail while writing MvcTestingAppManifest.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, shell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.