Search code examples
postsharp

Build error with PostSharp 2.1.6 (NuGet)


I am evaluating PostSharp for a new project but cannot seem to get past the following error when I first build the project after changes:

Cannot copy file "C:\SourcePath\Output\Debug\MyApp.vshost.exe to obj\Debug\Before-PostSharp\MyApp.vshost.exe: the file is locked by process(es):MYAPP.VSHOST (8064)

The error only occurs in the first build attempt. If I immediately re-build, the error does not occur. I can only guess this is because the project isn't actually being rebuilt the second time.

I've read a few posts in the SharpCrafters forum that indicate this problem existed prior to v2.1 but was reportedly fixed. I am using v2.1.6.14 from NuGet (in VS 2010) and getting this error for every project I reference PostSharp. It is certainly not reasonable to require 2 builds every time, so I'm looking for a possible solution. I'm really pleased with what I've seen thus far but will have to go another direction if that can't be resolved.

UPDATE

Per Gael's request, I generated the diagnostic build log and sent it to him and it looks like he was able to resolve the problem in the latest release (2.1.6.14).

I believe part (or all) of the issue may be due to the fact that the build output for all of my projects is set to a common location (i.e. not the /bin/debug folder under each project). This is because we are using a MEF DirectoryCatalog which will discover Imports and Exports contained in the assemblies located in the output path. The PostSharp.targets file has the vshost.exe file excluded from the copy operation but only when it shares the name of the output assembly. In my case, the vshost.exe file has a different name and was, therefore, not being excluded.


Solution

  • The issue has been re-fixed in PostSharp 2.1.6.15.