how to write cross platform postbuild event in dotnet core

Viewed 307

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>
1 Answers

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>
Related