C#等价于#If TARGET =" winexe" [英] C# equivalent for #If TARGET = "winexe"

查看:142
本文介绍了C#等价于#If TARGET =" winexe"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Basic中,要确定构建配置(子系统),您可以:



In Visual Basic, to determine the build config (subsystem) you can go:

#If TARGET = "winexe" Then
        ' Insert code to be compiled for a Windows application.
#ElseIf TARGET = "exe" Then
        ' Insert code to be compiled for a console application.
#End If





C#中的等价物是什么?



谢谢!



What is the equivalent in C#?

Thanks!

推荐答案

我发现了一些静态解决方案,但是考虑到这个悲惨的目标,它还有一些开发时间,我还没准备好投入。我可以解释这个想法。



要理解它,请查看项目文件。它具有XML节点 OutputFile 。例如,它可能是

I found some static solution, but it would some development time, which I'm not ready to dedicate, taking into account the miserable goal. I can explain the idea.

To understand it, look at the project file. It has the XML node OutputFile. For example, it could be
<OutputType>WinExe</OutputType>






or

<OutputType>Exe</OutputType>





现在,基于XML的MSBuild项目文件语言具有 Condition 属性等功能。你会看到类似



Now, the XML-based MSBuild project file language has such a feature as Condition attribute. You will see something like

<PropertyGroup Condition=" '


(配置)|


(平台)'=='调试| AnyCPU' >
(Platform)' == 'Debug|AnyCPU' ">



你可以写

条件属性。你会看到类似


and you can write
Condition attribute. You will see something like

<PropertyGroup Condition=" '


这篇关于C#等价于#If TARGET =&quot; winexe&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆