fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

F# console app cannot be built after diagnostic/instrumentation session

Open daniel-wojcik opened this issue 3 years ago • 1 comments

Create F# console application (.NET 6), then invoke Debug/Performance Profiler and check Instrumentation checkbox. Press Start button and select module in Start Instrumentation Profiling dialog and OK. Wait until profiling finishes. Output window contains the following line:

The process cannot access the file 'C:\Users\Daniel.Wojcik\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\net6.0\ConsoleApp1.dll' because it is being used by another process.

From this point application cannot be built/rebuilt and the follwing errors comes:

Unable to delete file "C:\Users\Daniel.Wojcik\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\net6.0\ConsoleApp1.dll".
Unable to delete file "C:\Users\Daniel.Wojcik\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\net6.0\FSharp.Core.dll".
Could not copy "obj\Debug\net6.0\ConsoleApp1.dll" to "bin\Debug\net6.0\ConsoleApp1.dll". Beginning retry 1 in 1000ms.
Could not copy "obj\Debug\net6.0\ConsoleApp1.dll" to "bin\Debug\net6.0\ConsoleApp1.dll". Beginning retry 2 in 1000ms.

Windows 10 21H2 + VS 2022 17.3 Preview 1.0

daniel-wojcik avatar May 23 '22 16:05 daniel-wojcik

This feels like a VS bug - does the same thing really not happen for a C# program?

dsyme avatar Sep 21 '22 13:09 dsyme

I have checked it in 17.6, in F# and C#, and in F# it does fail:

Restored C:\Users\vlza\source\repos\ConsoleApp2FS\ConsoleApp2FS\ConsoleApp2FS.fsproj (in 3 ms).
1>C:\Program Files\dotnet\sdk\7.0.200-preview.22628.1\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5652,5): warning MSB3061: Unable to delete file "C:\Users\vlza\source\repos\ConsoleApp2FS\ConsoleApp2FS\bin\Debug\net6.0\ConsoleApp2FS.dll". The process cannot access the file 'C:\Users\vlza\source\repos\ConsoleApp2FS\ConsoleApp2FS\bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process.
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5652,5): warning MSB3061: Unable to delete file "C:\Users\vlza\source\repos\ConsoleApp2FS\ConsoleApp2FS\bin\Debug\net6.0\FSharp.Core.dll". The process cannot access the file 'C:\Users\vlza\source\repos\ConsoleApp2FS\ConsoleApp2FS\bin\Debug\net6.0\FSharp.Core.dll' because it is being used by another process.
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 2 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4685,5): warning MSB3026: Could not copy "obj\Debug\net6.0\ConsoleApp2FS.dll" to "bin\Debug\net6.0\ConsoleApp2FS.dll". Beginning retry 7 in 1000ms. The process cannot access the file 'bin\Debug\net6.0\ConsoleApp2FS.dll' because it is being used by another process. The file is locked by: "Microsoft Visual Studio 2022 Preview (15024)"

And in C# case:

Rebuild started...
1>------ Rebuild All started: Project: ConsoleApp2CS, Configuration: Debug Any CPU ------
Restored C:\Users\vlza\source\repos\ConsoleApp2CS\ConsoleApp2CS\ConsoleApp2CS.csproj (in 2 ms).
1>C:\Program Files\dotnet\sdk\7.0.200-preview.22628.1\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>ConsoleApp2CS -> C:\Users\vlza\source\repos\ConsoleApp2CS\ConsoleApp2CS\bin\Debug\net6.0\ConsoleApp2CS.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild started at 4:58 PM and took 00.251 seconds ==========

However, in C# case it doesn't show the profiling results.

According to Resource Monitor, devenv.exe is hodling a handle to the dll. Probably a result of the instrumentation session.

@KevinRansom do you know whom can we talk to about it?

vzarytovskii avatar Jan 23 '23 16:01 vzarytovskii

This has to be reported via internal visual studio feedback tool, so it gets to the correct team (or in case if it gets to us, we ask to route it to whoever is responsible for the instrumentation session).

vzarytovskii avatar Oct 11 '23 13:10 vzarytovskii