Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Prebuild or Postbuild to dotnet core projects

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

like image 904
Dmehro Avatar asked Oct 18 '22 22:10

Dmehro


2 Answers

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

"scripts": {
    "precompile": [ "echo before" ],
    "postcompile": [ "echo after" ]
}
like image 190
Ricardo Fontana Avatar answered Oct 29 '22 17:10

Ricardo Fontana


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>
like image 24
Wallace Kelly Avatar answered Oct 29 '22 19:10

Wallace Kelly