【问题标题】:Adding C# preprocesor's directive in command-line building在命令行构建中添加 C# 预处理器的指令
【发布时间】:2010-10-05 14:05:12
【问题描述】:

对于 C++ 项目,我可以这样做:

SET CL=/DMYDIRECTIVE
devenv.exe MySolution.sln /rebuild

这个技巧的 C# 版本(visual studio 2008)是什么?

【问题讨论】:

    标签: visual-studio command-line


    【解决方案1】:

    转到项目属性中的构建选项卡

    在命令行上,csc /define:MYDIRECTIVE

    【讨论】:

      【解决方案2】:

      以下命令列出了 C# 编译器的选项

      csc.exe /?
      

      相应的选项是

      /define:<symbol list>   Define conditional compilation symbol(s) (Short form: /d)
      

      但是,对于命令行构建 C# 项目,您可能更喜欢 MSBuild。使用 MSBuild,使用 Visual Studio 的 Configuration Manager 创建配置可能是最简单的,它已经定义了适当的条件编译符号。然后,您可以从 MSBuild 命令行中选择一种配置:

      MSBuild MySolution.sln /t:Rebuild /p:Configuration=ReleaseWithMyDirective
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-11
        • 2023-03-05
        • 2021-05-01
        • 2014-01-09
        • 2010-12-19
        相关资源
        最近更新 更多