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

Dmehro
  • 1,269
  • 1
  • 16
  • 29

2 Answers2

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>
Wallace Kelly
  • 15,565
  • 8
  • 50
  • 71
2

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

"scripts": {
    "precompile": [ "echo before" ],
    "postcompile": [ "echo after" ]
}
Ricardo Fontana
  • 4,583
  • 1
  • 21
  • 32