在建的事件使用编译器常量
-
23-09-2019 - |
题
反正是有使用编译器常量在生成事件在Visual Studio - VB.NET? (特别是在生成后事件)
<强>方案强>
如果TEST_EDITION=TRUE
定义我想运行生成后事件中的可执行文件,所以如果它的FALSE
然后我会跑别的东西。
这可被用于创建不同版本的不同的安装程序。
P.S。有人建议前:不,我不希望使用楠,MSBuild的或类似的的
东西解决方案
是,则$(DefineConstants)宏可用,并且可以在生成事件进行测试。例如,项目+编译,高级编译选项,自定义常量=测试可以像这样进行测试:
if /i "$(DefineConstants)" NEQ "TEST" goto skiptest
echo Setting up for test environment
:skiptest
像测试= TRUE或化合物常数更复杂的自定义常量需要以不同的解析。诚然,我很快就放弃了试图找出如何使用可怕的 FOR命令。
其他提示
您是否尝试过的MSBuild PostEvents?这是一个的.csproj的提取物...但同样适用于vbproj文件
<!-- 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>
可以与 TaskExec 目标,这允许使用它你运行批处理文件或可执行文件。
<Target Name="DoSomething">
<Exec Command="D:\DoSomething.exe"/>
</Target>
不确定Visual Basic的语法,但以下特技可用于通过C ++:该文件global_inc.bat读作:
SET PARAMETER=TRUE
这可以是通过间歇脚本将其称为在生成后事件输入。 C ++代码中使用的文件,如下所示:
#define PARAMETER const int parameter
#define SET /**/
#include "global_inc.bat"
;
#undef PARAMETER
在postbuild步骤是这样的:
call global_inc.bat
if "%PARAMETER%" == "TRUE" echo True
另一种可能性是用于预生成步骤,以产生一个.vb
文件,以及在postbuild工序中使用的配置文件。
不隶属于 StackOverflow