emerbrito / ILMerge-MSBuild-Task

Adds ILMerge to Visual Studio 2013/2017 or automated builds. This Task is intended to work right out of the box however, it supports a configuration file where you can control every ILMerge property including the list of assemblies to be merged.
MIT License
54 stars 15 forks source link

The process cannot access the file 'bin\Debug\MyAssembly.pdb' because it is being used by another process. #24

Closed icnocop closed 5 years ago

icnocop commented 5 years ago

Hi.

Thank you for ILMerge.MSBuild.Task.

When I try to build my assembly and there's a missing (indirect) assembly reference, I get the following error:

1>C:\MyAssembly\packages\ILMerge.MSBuild.Task.1.0.5\build\ILMerge.MSBuild.Task.targets(13,5): error : Unresolved assembly reference not allowed: MyMissingReference.

After I add the missing reference and rebuild, I get an unexpected error:

1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(3863,5): error MSB3027: Could not copy "obj\Debug\MyAssembly.pdb" to "bin\Debug\MyAssembly.pdb". Exceeded retry count of 10. Failed.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(3863,5): error MSB3021: Unable to copy file "obj\Debug\MyAssembly.pdb" to "bin\Debug\MyAssembly.pdb". The process cannot access the file 'bin\Debug\MyAssembly.pdb' because it is being used by another process.

The issue is that a file handle to bin\Debug\MyAssembly.pdb is left open after the first build error.

As a work-around, I have to close Visual Studio, re-open the solution, and rebuild again.

Thank you.

icnocop commented 5 years ago

The same thing happens after this error:

1>C:\MyAssembly\packages\ILMerge.MSBuild.Task.1.0.5\build\ILMerge.MSBuild.Task.targets(13,5): error : ILMerge.Merge: ERROR!!: Duplicate type 'MyOtherType' found in assembly 'MyOtherAssembly'. Do you want to use the /allowDup option?

I'm using this with the nuget package ILMerge by mbarnett v3.0.21.

emerbrito commented 5 years ago

This appears to be same issues described in here #16 where ILMerge's target is trying to override Visual Studio's output. If you want ILMerge to also produce a pdb file your best bet is to output to a different folder. This can be achieved through the #configuration file.