Welcome to Microsoft Q&A!
You can try use AfterTargets.
This is my csproj file:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AssemblyName>MSBuildSample</AssemblyName>
<OutputPath>Bin\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="helloworld.cs" />
</ItemGroup>
<ItemGroup>
<ins Include="a.txt" />
<outs Include="b.txt" />
</ItemGroup>
<Target Name="Build" Inputs="@(Compile)" Outputs="$(OutputPath)$(AssemblyName).exe">
<MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
<Csc Sources="@(Compile)" OutputAssembly="$(OutputPath)$(AssemblyName).exe" />
</Target>
<Target Name="ExecuteTarget" Inputs="@(ins)" Outputs="@(outs)" AfterTargets="Build">
<Exec Command="echo Well Done" />
</Target>
</Project>
Sincerely,
Peng
*
If you have extra questions about this answer, please click "Comment". If the answer is the right solution, please click "Accept Answer" and kindly upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.