Bogey
Bogey

Reputation: 5734

Neither xcopy nor MSBuild CopyTask actually copy outfile file

I have a main application, which uses MEF to load plugins, as well as several projects for plugins. For the plugin projects, I'm trying to define a post-build action for each, which copies all output files into a \plugins\ subdirectory of my main application.

So for example copy all files from C:\path to solution\MySolution\DummyPlugin\bin\x86\Debug\*.* into C:\path to solution\MySolution\MainApplication\bin\x86\Debug\Plugins\

I'm using a build event

xcopy "$(ProjectDir)$(OutDir)*" "$(SolutionDir)MainApplication\$(OutDir)Plugins\" /D /y /s /r

Which seems to work fine for 2 out of my 3 plugin projects. But for my last project, whose output assembly is Service.dll, this seems to fail - as in, the file isn't copied.

I've tried substituting the build event with a MSBuild Task as follows,

<Target Name="AfterBuild">
  <CreateItem Include="$(ProjectDir)$(OutDir)*.*">
    <Output TaskParameter="Include" ItemName="PluginFiles"/>
  </CreateItem>
  <Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(SolutionDir)MainApplication\$(OutDir)Plugins\" ContinueOnError="false" />
</Target>

and even tried just coying Service.dll specifically,

<Target Name="AfterBuild">
  <Copy SourceFiles="$(ProjectDir)$(OutDir)Service.dll" DestinationFolder="$(SolutionDir)MainApplication\$(OutDir)Plugins\" ContinueOnError="false" />
</Target>

In each case, compiling works fine, there is no error output or anything whatsoever. But the files just aren't being copied.

Does anyhave have any clue what's going on there?! This is probably some really stupid problem, but since there are no errors or no output whatsoever, not sure how to track down the issue any further..

Thanks

Upvotes: 1

Views: 246

Answers (1)

Rob
Rob

Reputation: 464

file probably still be 'in use' by msbuild (buffered write) - sometimes the post build already starts before done fully writing.

Upvotes: 1

Related Questions