- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Stack Overflow 上阅读了很多文章,这些文章回答了“如何从 MSBuild 命令行将预处理器定义传递给编译器”这一问题,它们都以以下一些变化进行了回应:
MSBuild.exe /p:DefineConstants=THING_TO_BE_DEFINED
我已经尝试了我能想到的所有变体:
MSBuild.exe "/p:DefineConstants=THING_TO_BE_DEFINED"
MSBuild.exe /p:DefineConstants="THING_TO_BE_DEFINED"
MSBuild.exe "/p:DefineConstants=THING_TO_BE_DEFINED=1"
MSBuild.exe /p:DefineConstants="THING_TO_BE_DEFINED=1"
...以及其他几十个。我还以类似的方式尝试过重写 PreprocessorDefinitions。它们都触发了下面的#error:
#include "stdafx.h"
#if !defined(THING_TO_BE_DEFINED)
#error "THING_TO_BE_DEFINED is not defined"
#endif
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
我一直在使用上面的简单命令行应用程序以及我这里的一个巨大的游戏项目进行尝试。我只能猜测 Visual Studio(我在 2005 年和 2008 年看到了这一点)在其内部深处设置了一些默认设置,阻止了我的命令行参数的应用,但我没有发现任何证据来支持这个假设。/p>
关于如何让它发挥作用有什么想法吗?为什么以 FSM 的名义,他们不坚持使用好的 ol'-D THING_TO_BE_DEFINED?
最佳答案
如果您在命令行上调用 MSBuild,则无法指定 DefineConstants 的值。但如果您正在构建 .csproj 或另一个 MSBuild 脚本,则可以指定它。如果您创建一个 msbuild 文件来“替换”您的解决方案文件,那么您可以在构建项目时使用该文件并为其指定值。例如:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Default value here -->
<DefineConstants Condition=" '$(DefineConstants)'==''" >DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Projects Include="one.csproj" />
<Projects Include="two.csproj" />
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="@(Projects)"
Properties="DefineConstants=$(DefineConstants)"/>
</Target>
</Project>
然后您可以使用msbuild.exe buid.proj/p:DefineConstants="YourValue;Debug;Trace"
注意命令行中引号的用法。
我不久前写了一篇关于与此相关的博客文章,网址为 http://sedodream.com/2008/05/07/MSBuildBuildingTheSameProjectMultipleTimes.aspx .
关于command-line - MSBuild.exe 不接受任一/p :DefineConstants nor/p:PreprocessorDefinitions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2016697/
使用cats.Semigroup可以这样写: import cats.Semigroup import cats.implicits._ val l1: String Either Int = Lef
所以我的网页中有两个字段,一个用于电话号码,另一个用于电子邮件地址,我需要使用 JavaScript 而不是 jQuery 来填写其中之一。我在这里找到的大多数答案都是针对 jQuery 的,任何使用
我有一个类型,它的形状是这样的: val myType: Future[Either[MyError, TypeA]] = // some value 我知道我可以对此进行模式匹配并获得 Right
我的印象是某处有 Either a 的实例,但我似乎找不到它。我尝试导入 Control.Monad、Control.Monad.Instances 和 Data.Either,如图所示 module
我在一个宠物 Scala 项目中遇到了一个我真的不知道如何克服的情况。 以下示例显示了我的问题。 import scala.concurrent.Future import scala.concurr
我是一名优秀的程序员,十分优秀!