5

I need some help writing a post build event that would work cross platform. The following in my csproj file will work on windows but not Unix. Thanks.

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="copy /Y &quot;$(TargetDir)bin\*.dll&quot; &quot;$(TargetDir)*.dll&quot;" />
  </Target>
Kevin Tran
  • 137
  • 1
  • 8

1 Answers1

5

For this specific case, it might be easier to use the MSBuild Copy Task.

In your csproj file:

    <ItemGroup>
        <MySourceFiles Include=$(TargetDir)\bin\*.dll"/>
    </ItemGroup>

    <Target Name="CopyFiles">
        <Copy
            SourceFiles="@(MySourceFiles)"
            DestinationFolder="$(TargetDir)"
        />
    </Target>

That being said, Windows will happily accept / as a path separator, even mixing them in the same string.

ESG
  • 8,988
  • 3
  • 35
  • 52