Beispiel #1
0
        protected override string GenerateCommandLineCommands()
        {
            var  args = new ProcessArgumentBuilder();
            bool msym;

            args.Add("/verbose");

            if (Debug)
            {
                args.Add("/debug");
            }

            if (!string.IsNullOrEmpty(OutputPath))
            {
                args.AddQuoted("/output:" + Path.GetFullPath(OutputPath));
            }

            if (!string.IsNullOrEmpty(ApplicationName))
            {
                args.AddQuoted("/name:" + ApplicationName);
            }

            if (TargetFrameworkIdentifier == "Xamarin.Mac")
            {
                args.Add("/profile:Xamarin.Mac");
            }
            else if (TargetFrameworkVersion.StartsWith("v", StringComparison.Ordinal))
            {
                args.Add("/profile:" + TargetFrameworkVersion.Substring(1));
            }

            XamMacArch arch;

            if (!Enum.TryParse(Architecture, true, out arch))
            {
                arch = XamMacArch.Default;
            }

            if (arch == XamMacArch.Default)
            {
                arch = XamMacArch.x86_64;
            }

            if (arch.HasFlag(XamMacArch.i386))
            {
                args.Add("/arch:i386");
            }

            if (arch.HasFlag(XamMacArch.x86_64))
            {
                args.Add("/arch:x86_64");
            }

            if (!string.IsNullOrEmpty(ArchiveSymbols) && bool.TryParse(ArchiveSymbols.Trim(), out msym))
            {
                args.Add("--msym:" + (msym ? "yes" : "no"));
            }

            args.Add(string.Format("--http-message-handler={0}", HttpClientHandler));

            if (AppManifest != null)
            {
                try {
                    var plist = PDictionary.FromFile(AppManifest.ItemSpec);

                    PString v;
                    string  minimumDeploymentTarget;

                    if (!plist.TryGetValue(ManifestKeys.LSMinimumSystemVersion, out v) || string.IsNullOrEmpty(v.Value))
                    {
                        minimumDeploymentTarget = SdkVersion;
                    }
                    else
                    {
                        minimumDeploymentTarget = v.Value;
                    }

                    args.Add(string.Format("/minos={0}", minimumDeploymentTarget));
                }
                catch (Exception ex) {
                    Log.LogWarning(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Error loading '{0}': {1}", AppManifest.ItemSpec, ex.Message);
                }
            }

            if (TargetFrameworkIdentifier == "Xamarin.Mac" && !string.IsNullOrEmpty(TLSProvider))
            {
                args.Add(string.Format("--tls-provider={0}", TLSProvider.ToLowerInvariant()));
            }

            if (Profiling)
            {
                args.Add("/profiling");
            }

            switch ((LinkMode ?? string.Empty).ToLower())
            {
            case "full":
                break;

            case "sdkonly":
                args.Add("/linksdkonly");
                break;

            default:
                args.Add("/nolink");
                break;
            }

            if (!string.IsNullOrEmpty(I18n))
            {
                args.AddQuoted("/i18n:" + I18n);
            }

            if (ExplicitReferences != null)
            {
                foreach (var asm in ExplicitReferences)
                {
                    args.AddQuoted("/assembly:" + Path.GetFullPath(asm));
                }
            }

            if (!string.IsNullOrEmpty(ApplicationAssembly))
            {
                args.AddQuoted(Path.GetFullPath(ApplicationAssembly + (IsAppExtension ? ".dll" : ".exe")));
            }

            if (!string.IsNullOrWhiteSpace(ExtraArguments))
            {
                args.Add(ExtraArguments);
            }

            if (NativeReferences != null)
            {
                foreach (var nr in NativeReferences)
                {
                    args.AddQuoted("/native-reference:" + Path.GetFullPath(nr));
                }
            }

            if (IsAppExtension)
            {
                args.AddQuoted("/extension");
            }

            args.Add("/sdkroot");
            args.AddQuoted(SdkRoot);

            if (!string.IsNullOrEmpty(IntermediateOutputPath))
            {
                Directory.CreateDirectory(IntermediateOutputPath);

                args.Add("--cache");
                args.AddQuoted(Path.GetFullPath(IntermediateOutputPath));
            }

            return(args.ToString());
        }