所以,这个和这个都很清楚.简单地通过/p:DefineConstants="SYMBOL"
它对我来说根本不起作用,即使在测试项目中也是如此.我期望传递/ p:DefineConstants ="SYMBOL"将覆盖csproj中定义的任何条件编译常量.不是这样的......
完整代码列表如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DefineConstants
{
class Program
{
static void Main(string[] args)
{
#if DEV
Console.WriteLine("DEV");
#elif UAT
Console.WriteLine("UAT");
#else
Console.WriteLine("No environment provided");
#endif
}
}
}
Run Code Online (Sandbox Code Playgroud)
.csproj文件是:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{57A2E870-0547-475C-B0EB-66CF9A2FE417}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DefineConstants</RootNamespace>
<AssemblyName>DefineConstants</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> …Run Code Online (Sandbox Code Playgroud) 有没有人使用MonoDroid成功设置自定义标题?
此代码失败:
base.OnCreate (bundle);
SetContentView (Resource.Layout.WordSearchLayout);
//Customise the title bar
if (this.Window.RequestFeature(WindowFeatures.CustomTitle))
{
this.Window.SetFeatureInt (WindowFeatures.CustomTitle, Resource.Layout.custom_title);
}
Run Code Online (Sandbox Code Playgroud)
奇怪的是,它在调用RequestFeature异常时失败了requestFeature() must be called!.
I/MonoDroid(26052): UNHANDLED EXCEPTION: Android.Util.AndroidRuntimeException: Exception of type 'Android.Util.AndroidRuntimeException' was thrown.
I/MonoDroid(26052): at Android.Runtime.JNIEnv.CallBooleanMethod (intptr,intptr,Android.Runtime.JValue[]) <0x0007c>
I/MonoDroid(26052): at Android.Views.Window.RequestFeature (Android.Views.WindowFeatures) <0x00157>
I/MonoDroid(26052): at com.xxx.android.WordSearchActivity.OnCreate (Android.OS.Bundle) <0x0013b>
I/MonoDroid(26052): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x0005f>
I/MonoDroid(26052): at (wrapper dynamic-method) object.1a40b50f-d523-4f52-b291-bcedd3a88965 (intptr,intptr,intptr) <0x00033>
I/MonoDroid(26052):
I/MonoDroid(26052): --- End of managed exception stack trace ---
I/MonoDroid(26052): android.util.AndroidRuntimeException: requestFeature() must be called before adding …Run Code Online (Sandbox Code Playgroud)