Is it possible to change the file build action in pre-build events?

I want the file (robots.txt) to publish only when I use a specific build configuration. Is there a way to handle this in pre-build events?

+4
source share
2 answers

Another option is to use the $ (ConfigurationName) macro in the VisualStudio assembly event editor:

if $(ConfigurationName)=="Production" copy robots.txt destinationpath 
+3
source

Yes you can do it. Two things you might need:

  • Manual work with a .proj file in a text editor (or Visual Studio when unloading a project)
  • Using conditional execution of MSBUILD

Sample code to get you started. Adjust it as desired.

 <Target Name="AfterBuild" Condition="'$(Configuration)'=='Production'"> <Copy SourceFiles=".../robot.txt" DestinationFolder="..."/> </Target> 
+4
source

Source: https://habr.com/ru/post/1490912/


All Articles