Reputation: 2507
I have the NuGet package which managed library depends on a native library. I want to copy native dependency to the \\UnmanagedLibraries\Windows\x86\ folder and I have made the following file which is copied to the build folder:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CopyNativeReferences">
<Message Text="$(MSBuildThisFileDirectory) => $(OutDir)\UnmanagedLibraries\Windows\x86\"></Message>
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\native\UnmanagedLibraries\Windows\x86\SIMDArrayInstructions.dll"
DestinationFolder="$(OutDir)\UnmanagedLibraries\Windows\x86\"
SkipUnchangedFiles="true" />
</Target>
<PropertyGroup>
<AfterBuildDependsOn>
CopyNativeReferences;
</AfterBuildDependsOn>
</PropertyGroup>
<Target Name="AfterBuild" DependsOnTargets="$(AfterBuildDependsOn)"/>
</Project>
It runs fine for one package, but I have multiple NuGet packages that need to copy their native references. After I install the second package, the native references for the first package are not copied. It seems that 'AfterBuild' is overwritten with the new package.
I also changed target name and AfterBuildDependsOn to ensure that other packages do not share same names of target variables but it did not help.
How can I resolve this?
Upvotes: 2
Views: 1441
Reputation: 2507
The defined property group should look like:
PropertyGroup>
<AfterBuildDependsOn>
$(AfterBuildDependsOn);
CopyNativeReferences;
</AfterBuildDependsOn>
</PropertyGroup>
Upvotes: 3