3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

Failed to write to log file ... because it is being used by another process #223

Open KieranRosinger opened 1 year ago

KieranRosinger commented 1 year ago

I'm having an issue with building a project using DLLExport when using a Directory.Build.rsp file to set the msbuild /fl1 flag.

The error that occurs is

"C:\DLLExportIssue\Test\Test.sln" (default target) (1) ->
"C:\DLLExportIssue\Test\Test.csproj" (default target) (2) ->
(DllExportRestorePkg target) ->
  MSBUILD : Logger error MSB4104: Failed to write to log file "msbuild1.log". The process cannot access
 the file 'C:\DLLExportIssue\Test\msbuild1.log' because it is being used by another process. [C:\DLLExp
ortIssue\Test\Test.csproj]
  C:\DLLExportIssue\Test\Test.csproj(34,5): error MSB3073: The command ".\DllExport.bat  -action Restor
e" exited with code -1.

DLLExportIssue.zip

I have attached the solution and steps to reproduce. This is a new Hello World Console App .Net6.0 from Visual Studio 2022 with DLLExport installed onto the project.

The issue is only seen when a Directory.Build.rsp file is present in the solution folder that sets msbuild flag /fl1.

Please can you advise if there is a work around or how I can resolve the issue?

3F commented 1 year ago

Hello,

Thanks for the prepared project example to reproduce. This is appreciated!

Conflict between processes due to several sources (+exec task in csproj) for a single destination is possible for filelogger. In order to avoid problem try to split dst or use other logger or redirect std stream OR call DllExport.bat separately before msbuild

For example,

DllExport -action Restore

Then,

msbuild -t:Restore -t:Build

On 05.05.2023 16:13, KieranRosinger wrote:

I'm having an issue with building a project using DLLExport when using a Directory.Build.rsp file to set the msbuild /fl1 flag.

The error that occurs is

|"C:\DLLExportIssue\Test\Test.sln" (default target) (1) -> "C:\DLLExportIssue\Test\Test.csproj" (default target) (2) -> (DllExportRestorePkg target) -> MSBUILD : Logger error MSB4104: Failed to write to log file "msbuild1.log". The process cannot access the file 'C:\DLLExportIssue\Test\msbuild1.log' because it is being used by another process. [C:\DLLExp ortIssue\Test\Test.csproj] C:\DLLExportIssue\Test\Test.csproj(34,5): error MSB3073: The command ".\DllExport.bat -action Restor e" exited with code -1. |

DLLExportIssue.zip https://github.com/3F/DllExport/files/11332679/DLLExportIssue.zip

I have attached the solution and steps to reproduce. This is a new Hello World Console App .Net6.0 from Visual Studio 2022 with DLLExport installed onto the project.

The issue is only seen when a Directory.Build.rsp file is present in the solution folder that sets msbuild flag /fl1.

Please can you advise if there is a work around or how I can resolve the issue?

KieranRosinger commented 1 year ago

Thanks, I have added a step to the build process outside of the MSBuild system that calls "DllExport -action Restore" before calling MSBuild to compile. This work around is sufficeint in our workflow.