Using compiler constants in build events

Can I use compiler constants in build events in Visual Studio - VB.NET? (especially in post-build events)

Scenario

If defined TEST_EDITION=TRUE, I want to run the executable during the Post-Build event, so if it is FALSE, then I ran something else.

This can be used to create different installers for different releases.

PS Before someone tells me: No, I do not want to use nant, msbuild or something like that

+5
source share
3 answers

, $(DefineConstants) . , Project + Compile, Advanced Compile Options, Custom constants = Test :

if /i "$(DefineConstants)" NEQ "TEST" goto skiptest
echo Setting up for test environment
:skiptest

, Test = TRUE , -. , , , FOR.

+11

Visual Basic, ++ : global_inc.bat :

SET PARAMETER=TRUE

script, . ++ :

#define PARAMETER const int parameter
#define SET /**/
#include "global_inc.bat"
;
#undef PARAMETER

postbuild :

call global_inc.bat
if "%PARAMETER%" == "TRUE" echo True

prebuild - .vb, , postbuild.

0

Have you tried MsBuild PostEvents? this is an excerpt from .csproj ... but the same goes for vbproj files.

  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
    <Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFolder="$(BinariesFolder)" ContinueOnError="true" />
  </Target>

You can use it with TaskExec Target, which allows you to run a batch file or an executable file.

<Target Name="DoSomething">
    <Exec Command="D:\DoSomething.exe"/>
</Target>
0
source

All Articles