简体   繁体   English

VC# 中项目类型(目标)的预编译器概念

[英]Precompiler notion for project type (target) in VC#

Just the same as if a project in DEBUG / RELEASE mode We use就像一个项目处于 DEBUG / RELEASE 模式一样 我们使用

#ifdef DEBUG
...

Is there something the same for TARGET? TARGET 有相同的东西吗? (exe / lib / winexe) ? (exe / lib / winexe) ?

There isn't anything built in, but in your build you can define anything you like ;没有内置任何东西,但在你的构建中你可以定义任何你喜欢的东西 this could be done manually per-project, or you can do it more dynamically;这可以按项目手动完成,或者您可以更动态地完成; here's an example that conditionally appends a PLAT_NO_EMITDLL symbol if the target framework is (either of a few), so that the code can #if PLAT_NO_EMITDLL rather than having all the "which framework has what platform features" logic in the C# files:这是一个示例,如果目标框架是(几个),则有条件地附加一个PLAT_NO_EMITDLL符号,以便代码可以#if PLAT_NO_EMITDLL而不是在 C# 文件中具有所有“哪个框架具有哪些平台功能”逻辑:

  <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
    <DefineConstants>$(DefineConstants);PLAT_NO_EMITDLL</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
    <DefineConstants>$(DefineConstants);PLAT_NO_EMITDLL</DefineConstants>
  </PropertyGroup>

In your case, you might want to look at $(OutputType) .在您的情况下,您可能需要查看$(OutputType)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM