7

Is there any way to add prebuild/postbuild options in dotnet core projects in Visual Studio ?

There is no option to add build events in project properties as it used to be with Standard dot net projects standard dot net project properties

Dot net core projects with no build events option

4
  • See stackoverflow.com/questions/37596115/…
    – stuartd
    Nov 9, 2016 at 22:07
  • I create a demo and test Ricardo Fontana's answer. it works. do you resolve your issue? if not, could you please provide further information? Nov 15, 2016 at 6:21
  • @ColeWu yes it solves the problem. Thanks
    – Dmehro
    Nov 15, 2016 at 20:33
  • If the answer is helpful, please mark it as an answer, It will be very beneficial for other community members who have the similar questions Nov 17, 2016 at 7:18

2 Answers 2

3

Here is an example:

<Project... >
      :
  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="echo before" />
  </Target>
  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="echo after" />
  </Target>
      :
</Project>
2

According the documentation, you can add commands, in scripts section, in project.json file.

"scripts": {
    "precompile": [ "echo before" ],
    "postcompile": [ "echo after" ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.