Skip to content

Add retry when writing to files that can be in use by another process #21

@Measurity

Description

@Measurity

Another process might be using files that the publicizer wants to write to. Having a retry mechanic would then improve the UX so user doesn't need to restart the build.

BepInEx.AssemblyPublicizer.MSBuild.props(17,9): Error MSB4018 : The "PublicizeTask" task failed unexpectedly.
System.IO.IOException: The process cannot access the file '.../publicized/Assembly-CSharp.dll' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Init(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Int64& fileLength, UnixFileMode& filePermissions)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.File.Create(String path)
   at BepInEx.AssemblyPublicizer.FatalAsmResolver.FatalWrite(ModuleDefinition module, String filePath)
   at BepInEx.AssemblyPublicizer.AssemblyPublicizer.Publicize(String assemblyPath, String outputPath, AssemblyPublicizerOptions options)
   at BepInEx.AssemblyPublicizer.MSBuild.PublicizeTask.Execute() in /home/runner/work/BepInEx.AssemblyPublicizer/BepInEx.AssemblyPublicizer/BepInEx.AssemblyPublicizer.MSBuild/PublicizeTask.cs:line 116
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions