A temp dll already in use?
Many times when I try to build a project using SwaggerProvider, the build fails for a temporary dll being unable to access. If I retry the second time, it works fine. Can this be because, for example, the design-time and the compile-time try to access the same dll at the same time?
- Could we use another dll instead?
- Or maybe open the file with different read/write rights? (Overwrite.)
- Or maybe use some synchronization concepts like MailBoxProcessor, or a simple one-time-retry of "wait 3 sec and retry"?
Or could these possibly cause the built dll be corrupted somehow?
This is a stack trace:
error FS3033: The type provider 'SwaggerProvider.SwaggerTypeProvider' reported an error: Could not open file for writing (binary mode): C:\Users\(user)\AppData\Local\Temp\tmp837A.dll
System.IO.IOException: The process cannot access the file 'C:\Users\(user)\AppData\Local\Temp\tmp837A.dll' 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)
at ProviderImplementation.ProvidedTypes.BinaryWriter.writeBinaryAndReportMappings[a,b,c,d,e](String outfile, ILGlobals ilg, FSharpOption`1 pdbfile, a portablePDB, Boolean embeddedPDB, b embedAllSource, c embedSourceList, d sourceLink, Boolean emitTailcalls, Boolean deterministic, Boolean showTimes, e dumpDebugInfo, ILModuleDef modul)
It may happen because we cache provided assemblies https://github.com/fsprojects/SwaggerProvider/blob/master/src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs#L88
in theory, different parts of ide may get the same cached assembly... Is it an error from the IDE or the console?
Visual Studio 2022 build command, the build fails for this. It happens, e.g. with this library https://github.com/Thorium/ClearBank.Net, but it seems to happen on others as well.
Do you have a similar issue with SQLProvider? Do you use caching inside?
No issues there, but it's an erasing TP so I guess the compilation is different.
The caching if that is here: https://github.com/fsprojects/SQLProvider/blob/c4c8c384a47f7a5fc06d4fdf404d2b34f415ba13/src/SQLProvider.DesignTime/SqlDesignTime.fs#L1148
But also I don't have issues with FSharp.Data.
I hit the same issue in Visual Studio, VSCode worked but only for version 2.1.0.