Exemplo n.º 1
0
		protected internal override void AddCommandLineCommands (
						CommandLineBuilderExtension commandLine)
		{
			if (Sources.Length == 0)
				return;

			foreach (ITaskItem item in Sources)
				commandLine.AppendSwitchIfNotNull ("--complist=", item.ItemSpec);

			commandLine.AppendSwitchIfNotNull ("--target=", LicenseTarget);

			if (ReferencedAssemblies != null)
				foreach (ITaskItem reference in ReferencedAssemblies)
					commandLine.AppendSwitchIfNotNull ("--load=", reference.ItemSpec);

			string outdir;
			if (Bag ["OutputDirectory"] != null)
				outdir = OutputDirectory;
			else
				outdir = ".";

			commandLine.AppendSwitchIfNotNull ("--outdir=", outdir);

			if (Bag ["NoLogo"] != null && NoLogo)
				commandLine.AppendSwitch ("--nologo");

			OutputLicense = new TaskItem (Path.Combine (OutputDirectory, LicenseTarget.ItemSpec + ".licenses"));
		}
 private void AddReferencesToCommandLine(CommandLineBuilderExtension commandLine)
 {
     if ((base.References != null) && (base.References.Length != 0))
     {
         List<ITaskItem> list = new List<ITaskItem>(base.References.Length);
         List<ITaskItem> list2 = new List<ITaskItem>(base.References.Length);
         foreach (ITaskItem item in base.References)
         {
             if (MetadataConversionUtilities.TryConvertItemMetadataToBool(item, "EmbedInteropTypes"))
             {
                 list2.Add(item);
             }
             else
             {
                 list.Add(item);
             }
         }
         if (list2.Count > 0)
         {
             commandLine.AppendSwitchIfNotNull("/link:", list2.ToArray(), ",");
         }
         if (list.Count > 0)
         {
             commandLine.AppendSwitchIfNotNull("/reference:", list.ToArray(), ",");
         }
     }
 }
 protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendSwitchIfNotNull("/lib:", base.AdditionalLibPaths, ",");
     commandLine.AppendPlusOrMinusSwitch("/unsafe", base.Bag, "AllowUnsafeBlocks");
     commandLine.AppendPlusOrMinusSwitch("/checked", base.Bag, "CheckForOverflowUnderflow");
     commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", new char[] { ';', ',' });
     commandLine.AppendWhenTrue("/fullpaths", base.Bag, "GenerateFullPaths");
     commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion);
     commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName);
     commandLine.AppendSwitchIfNotNull("/pdb:", this.PdbFile);
     commandLine.AppendPlusOrMinusSwitch("/nostdlib", base.Bag, "NoStandardLib");
     commandLine.AppendSwitchIfNotNull("/platform:", this.Platform);
     commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport);
     commandLine.AppendSwitchWithInteger("/warn:", base.Bag, "WarningLevel");
     commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile);
     commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress);
     commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(base.DefineConstants));
     commandLine.AppendSwitchIfNotNull("/win32res:", base.Win32Resource);
     commandLine.AppendSwitchIfNotNull("/main:", base.MainEntryPoint);
     commandLine.AppendSwitchIfNotNull("/appconfig:", this.ApplicationConfiguration);
     this.AddReferencesToCommandLine(commandLine);
     base.AddResponseFileCommands(commandLine);
     commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", new char[] { ';', ',' });
     commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", new char[] { ';', ',' });
     if (base.ResponseFiles != null)
     {
         foreach (ITaskItem item in base.ResponseFiles)
         {
             commandLine.AppendSwitchIfNotNull("@", item.ItemSpec);
         }
     }
 }
Exemplo n.º 4
0
        /*
         * Method:      ValidateHasParameter
         *
         * Validates that the the given ToolTaskExtension's command line contains the indicated
         * parameter.  Returns the index of the parameter that matched.
         *
         */
        internal static int ValidateHasParameter(ToolTaskExtension t, string parameter, bool useResponseFile)
        {
            CommandLineBuilderExtension b = new CommandLineBuilderExtension();

            if (useResponseFile)
                t.AddResponseFileCommands(b);
            else
                t.AddCommandLineCommands(b);

            string cl = b.ToString();
            string msg = String.Format("Command-line = [{0}]\r\n", cl);
            msg += String.Format(" Searching for [{0}]\r\n", parameter);

            string[] pieces = Parse(cl);

            int i = 0;
            foreach (string s in pieces)
            {
                msg += String.Format(" Parm = [{0}]\r\n", s);
                if (s == parameter)
                {
                    return i;
                }

                i++;
            }

            msg += "Not found!\r\n";
            Console.WriteLine(msg);
            Assert.Fail(msg); // Could not find the parameter.

            return 0;
        }
Exemplo n.º 5
0
        private void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
        {
            string outputDirectory = Path.GetDirectoryName(this.OutputFile);

            if(!Directory.Exists( outputDirectory ))
                Directory.CreateDirectory( outputDirectory );

            commandLine.AppendSwitch( "-q" );
            if (m_inputDirectories != null)
            {
                commandLine.AppendSwitch("-r");
            }
            commandLine.AppendFileNameIfNotNull( this.m_outputFile );

            if (m_inputFiles != null)
            {
                foreach (ITaskItem inputFile in InputFiles)
                {
                    Log.LogMessage("Adding file {0}", inputFile.ItemSpec);
                    commandLine.AppendFileNameIfNotNull(inputFile.ItemSpec);
                }
            }

            if (m_inputDirectories != null)
            {
                foreach (ITaskItem inputDirectory in InputDirectories)
                {
                    Log.LogMessage("Adding directory {0}", inputDirectory.ItemSpec);
                    commandLine.AppendFileNameIfNotNull(inputDirectory.ItemSpec);
                }
            }
        }
Exemplo n.º 6
0
		void AddCommandLineCommands (CommandLineBuilderExtension commandLine)
		{
			if (Resources.Length == 0)
				return;

			commandLine.AppendFileNameIfNotNull (OutputFile);

			commandLine.AppendFileNamesIfNotNull (Resources, " ");
		}
Exemplo n.º 7
0
Arquivo: AL.cs Projeto: nlhepler/mono
		protected internal override void AddResponseFileCommands (
						 CommandLineBuilderExtension commandLine)
		{
			commandLine.AppendSwitchIfNotNull ("/algid:", AlgorithmId);
			commandLine.AppendSwitchIfNotNull ("/baseaddress:", BaseAddress);
			commandLine.AppendSwitchIfNotNull ("/company:", CompanyName);
			commandLine.AppendSwitchIfNotNull ("/configuration:", Configuration);
			commandLine.AppendSwitchIfNotNull ("/culture:", Culture);
			commandLine.AppendSwitchIfNotNull ("/copyright:", Copyright);
			if (Bag ["DelaySign"] != null)
				if (DelaySign)
					commandLine.AppendSwitch ("/delaysign+");
				else
					commandLine.AppendSwitch ("/delaysign-");
			commandLine.AppendSwitchIfNotNull ("/description:", Description);
			if (EmbedResources != null) {
				foreach (ITaskItem item in EmbedResources) {
					string logical_name = item.GetMetadata ("LogicalName");
					if (!string.IsNullOrEmpty (logical_name))
						commandLine.AppendSwitchIfNotNull ("/embed:", string.Format ("{0},{1}", item.ItemSpec, logical_name));
					else
						commandLine.AppendSwitchIfNotNull ("/embed:", item.ItemSpec);
				}
			}
			commandLine.AppendSwitchIfNotNull ("/evidence:", EvidenceFile);
			commandLine.AppendSwitchIfNotNull ("/fileversion:", FileVersion);
			commandLine.AppendSwitchIfNotNull ("/flags:", Flags);
			if (GenerateFullPaths)
				commandLine.AppendSwitch ("/fullpaths");
			commandLine.AppendSwitchIfNotNull ("/keyname:", KeyContainer);
			commandLine.AppendSwitchIfNotNull ("/keyfile:", KeyFile);
			if (LinkResources != null)
				foreach (ITaskItem item in LinkResources)
					commandLine.AppendSwitchIfNotNull ("/link:", item.ItemSpec);
			commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
			if (OutputAssembly != null)
				commandLine.AppendSwitchIfNotNull ("/out:", OutputAssembly.ItemSpec);
			//platform
			commandLine.AppendSwitchIfNotNull ("/product:", ProductName);
			commandLine.AppendSwitchIfNotNull ("/productversion:", ProductVersion);
			if (ResponseFiles != null)
				foreach (string s in ResponseFiles)
					commandLine.AppendFileNameIfNotNull (String.Format ("@{0}", s));
			if (SourceModules != null)
				foreach (ITaskItem item in SourceModules)
					commandLine.AppendFileNameIfNotNull (item.ItemSpec);
			commandLine.AppendSwitchIfNotNull ("/target:", TargetType);
			commandLine.AppendSwitchIfNotNull ("/template:", TemplateFile);
			commandLine.AppendSwitchIfNotNull ("/title:", Title);
			commandLine.AppendSwitchIfNotNull ("/trademark:", Trademark);
			commandLine.AppendSwitchIfNotNull ("/version:", Version);
			commandLine.AppendSwitchIfNotNull ("/win32icon:", Win32Icon);
			commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
		}
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     this.CreateTemporaryBatchFile();
     string batchFile = this.batchFile;
     commandLine.AppendSwitch("/Q");
     commandLine.AppendSwitch("/C");
     if (batchFile.Contains("&") && !batchFile.Contains("^&"))
     {
         batchFile = Microsoft.Build.Shared.NativeMethodsShared.GetShortFilePath(batchFile).Replace("&", "^&");
     }
     commandLine.AppendFileNameIfNotNull(batchFile);
 }
 protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
 {
     if (((this.OutputAssembly == null) && (this.Sources != null)) && ((this.Sources.Length > 0) && (this.ResponseFiles == null)))
     {
         try
         {
             this.OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(this.Sources[0].ItemSpec));
         }
         catch (ArgumentException exception)
         {
             throw new ArgumentException(exception.Message, "Sources");
         }
         if (string.Compare(this.TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
         {
             ITaskItem outputAssembly = this.OutputAssembly;
             outputAssembly.ItemSpec = outputAssembly.ItemSpec + ".dll";
         }
         else if (string.Compare(this.TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
         {
             ITaskItem item2 = this.OutputAssembly;
             item2.ItemSpec = item2.ItemSpec + ".netmodule";
         }
         else
         {
             ITaskItem item3 = this.OutputAssembly;
             item3.ItemSpec = item3.ItemSpec + ".exe";
         }
     }
     commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
     commandLine.AppendSwitchWithInteger("/codepage:", base.Bag, "CodePage");
     this.ConfigureDebugProperties();
     commandLine.AppendPlusOrMinusSwitch("/debug", base.Bag, "EmitDebugInformation");
     commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);
     commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign");
     commandLine.AppendSwitchWithInteger("/filealign:", base.Bag, "FileAlignment");
     commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
     commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
     commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
     commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo");
     commandLine.AppendWhenTrue("/nowin32manifest", base.Bag, "NoWin32Manifest");
     commandLine.AppendPlusOrMinusSwitch("/optimize", base.Bag, "Optimize");
     commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
     commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
     commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
     commandLine.AppendPlusOrMinusSwitch("/warnaserror", base.Bag, "TreatWarningsAsErrors");
     commandLine.AppendWhenTrue("/utf8output", base.Bag, "Utf8Output");
     commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
     commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);
     commandLine.AppendFileNamesIfNotNull(this.Sources, " ");
 }
Exemplo n.º 10
0
		protected internal override void AddCommandLineCommands (CommandLineBuilderExtension commandLine)
		{
			if (IsRunningOnWindows)
				commandLine.AppendSwitch ("/q /c");

			if (!String.IsNullOrEmpty (command)) {
				scriptFile = Path.GetTempFileName ();
				if (IsRunningOnWindows)
					scriptFile = scriptFile + ".bat";
				using (StreamWriter sw = new StreamWriter (scriptFile)) {
					sw.Write (command);
				}
				commandLine.AppendFileNameIfNotNull (scriptFile);
			}
			base.AddCommandLineCommands (commandLine);
		}
Exemplo n.º 11
0
        protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            if (OutputGeneratedFile != null && !String.IsNullOrEmpty(OutputGeneratedFile.ItemSpec))
                commandLine.AppendSwitchIfNotNull("/outputgeneratedfile:", OutputGeneratedFile);
            commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(base.DefineConstants));
            this.AddReferencesToCommandLine(commandLine);
            base.AddResponseFileCommands(commandLine);
            if (ResponseFiles != null)
            {
                foreach (ITaskItem item in ResponseFiles)
                {
                    commandLine.AppendSwitchIfNotNull("@", item.ItemSpec);
                }
            }
            if (ContentFiles != null)
            {
                foreach (var file in ContentFiles)
                {
                    commandLine.AppendSwitchIfNotNull("/contentfile:", file.ItemSpec);
                }
            }
            if (NoneFiles != null)
            {
                foreach (var file in NoneFiles)
                {
                    commandLine.AppendSwitchIfNotNull("/nonefile:", file.ItemSpec);
                }
            }
            if (SkcPlugins != null)
            {
                foreach (var file in SkcPlugins)
                {
                    commandLine.AppendSwitchIfNotNull("/plugin:", file.ItemSpec);
                }
            }
            if (SkcRebuild)
                commandLine.AppendSwitch("/rebuild");
            if (UseBuildService)
            {
                Log.LogMessage("CurrentDirectory is: " + Directory.GetCurrentDirectory());
                commandLine.AppendSwitchIfNotNull("/dir:", Directory.GetCurrentDirectory());
            }

            commandLine.AppendSwitchIfNotNull("/TargetFrameworkVersion:", TargetFrameworkVersion);
        }
Exemplo n.º 12
0
		public void ARFC (CommandLineBuilderExtension commandLine)
		{
			base.AddResponseFileCommands (commandLine);
#if !NET_4_0
			string s = commandLine.ToString ();
			if (s.Length == 6)
				Assert.AreEqual ("/sdk:2", s);
			else
				Assert.AreEqual ("/sdk:2 ", s.Substring (0, 7));

			BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
			PropertyInfo pi = typeof (CommandLineBuilderExtension).GetProperty ("CommandLine", flags);
			System.Text.StringBuilder sb = (System.Text.StringBuilder) pi.GetValue (commandLine, null);
			sb.Length = 0;
			if (s.Length > 6)
				sb.Append (s.Substring (7));
#endif
		}
        public void AppendItemWithInvalidBooleanAttribute()
        {
            Assert.Throws<ArgumentException>(() =>
            {
                // Construct the task item.
                TaskItem i = new TaskItem();
                i.ItemSpec = "MyResource.bmp";
                i.SetMetadata("Name", "Kenny");
                i.SetMetadata("Private", "Yes");       // This is our flag.

                CommandLineBuilderExtension c = new CommandLineBuilderExtension();

                // Validate that a legitimate bool works first.
                try
                {
                    c.AppendSwitchIfNotNull
                    (
                        "/myswitch:",
                        new ITaskItem[] { i },
                        new string[] { "Name", "Private" },
                        new bool[] { false, true }
                    );
                    Assert.Equal(@"/myswitch:MyResource.bmp,Kenny,Private", c.ToString());
                }
                catch (ArgumentException e)
                {
                    Assert.True(false, "Got an unexpected exception:" + e.Message);
                }

                // Now try a bogus boolean.
                i.SetMetadata("Private", "Maybe");       // This is our flag.
                c.AppendSwitchIfNotNull
                (
                    "/myswitch:",
                    new ITaskItem[] { i },
                    new string[] { "Name", "Private" },
                    new bool[] { false, true }
                );  // <-- Expect an ArgumentException here.
            }
           );
        }
 private void AddReferencesToCommandLine(CommandLineBuilderExtension commandLine)
 {
     if ((base.References != null) && (base.References.Length != 0))
     {
         foreach (ITaskItem item in base.References)
         {
             string metadata = item.GetMetadata("Aliases");
             string switchName = "/reference:";
             if (MetadataConversionUtilities.TryConvertItemMetadataToBool(item, "EmbedInteropTypes"))
             {
                 switchName = "/link:";
             }
             if ((metadata == null) || (metadata.Length == 0))
             {
                 commandLine.AppendSwitchIfNotNull(switchName, item.ItemSpec);
             }
             else
             {
                 foreach (string str3 in metadata.Split(new char[] { ',' }))
                 {
                     string str4 = str3.Trim();
                     if (str3.Length != 0)
                     {
                         if (str4.IndexOfAny(new char[] { ',', ' ', ';', '"' }) != -1)
                         {
                             Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgument(false, "Csc.AssemblyAliasContainsIllegalCharacters", item.ItemSpec, str4);
                         }
                         if (string.Compare("global", str4, StringComparison.OrdinalIgnoreCase) == 0)
                         {
                             commandLine.AppendSwitchIfNotNull(switchName, item.ItemSpec);
                         }
                         else
                         {
                             commandLine.AppendSwitchAliased(switchName, str4, item.ItemSpec);
                         }
                     }
                 }
             }
         }
     }
 }
 protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendSwitchIfNotNull("/algid:", this.AlgorithmId);
     commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress);
     commandLine.AppendSwitchIfNotNull("/company:", this.CompanyName);
     commandLine.AppendSwitchIfNotNull("/configuration:", this.Configuration);
     commandLine.AppendSwitchIfNotNull("/copyright:", this.Copyright);
     commandLine.AppendSwitchIfNotNull("/culture:", this.Culture);
     commandLine.AppendPlusOrMinusSwitch("/delaysign", base.Bag, "DelaySign");
     commandLine.AppendSwitchIfNotNull("/description:", this.Description);
     commandLine.AppendSwitchIfNotNull("/evidence:", this.EvidenceFile);
     commandLine.AppendSwitchIfNotNull("/fileversion:", this.FileVersion);
     commandLine.AppendSwitchIfNotNull("/flags:", this.Flags);
     commandLine.AppendWhenTrue("/fullpaths", base.Bag, "GenerateFullPaths");
     commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
     commandLine.AppendSwitchIfNotNull("/keyname:", this.KeyContainer);
     commandLine.AppendSwitchIfNotNull("/main:", this.MainEntryPoint);
     commandLine.AppendSwitchIfNotNull("/out:", (this.OutputAssembly == null) ? null : this.OutputAssembly.ItemSpec);
     commandLine.AppendSwitchIfNotNull("/platform:", this.Platform);
     commandLine.AppendSwitchIfNotNull("/product:", this.ProductName);
     commandLine.AppendSwitchIfNotNull("/productversion:", this.ProductVersion);
     commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
     commandLine.AppendSwitchIfNotNull("/template:", this.TemplateFile);
     commandLine.AppendSwitchIfNotNull("/title:", this.Title);
     commandLine.AppendSwitchIfNotNull("/trademark:", this.Trademark);
     commandLine.AppendSwitchIfNotNull("/version:", this.Version);
     commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
     commandLine.AppendSwitchIfNotNull("/win32res:", this.Win32Resource);
     commandLine.AppendSwitchIfNotNull("", this.SourceModules, new string[] { "TargetFile" });
     commandLine.AppendSwitchIfNotNull("/embed:", this.EmbedResources, new string[] { "LogicalName", "Access" });
     commandLine.AppendSwitchIfNotNull("/link:", this.LinkResources, new string[] { "LogicalName", "TargetFile", "Access" });
     if (this.ResponseFiles != null)
     {
         foreach (string str in this.ResponseFiles)
         {
             commandLine.AppendSwitchIfNotNull("@", str);
         }
     }
 }
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendSwitchIfNotNull("/target:", this.LicenseTarget.ItemSpec);
     foreach (ITaskItem item in this.Sources)
     {
         commandLine.AppendSwitchIfNotNull("/complist:", item.ItemSpec);
     }
     commandLine.AppendSwitchIfNotNull("/outdir:", this.OutputDirectory);
     if (this.ReferencedAssemblies != null)
     {
         foreach (ITaskItem item2 in this.ReferencedAssemblies)
         {
             commandLine.AppendSwitchIfNotNull("/i:", item2.ItemSpec);
         }
     }
     commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo");
     string str = this.LicenseTarget.ItemSpec + ".licenses";
     if (this.OutputDirectory != null)
     {
         str = Path.Combine(this.OutputDirectory, str);
     }
     this.OutputLicense = new TaskItem(str);
 }
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendSwitchIfNotNull("-m ", this.MetabasePath);
     commandLine.AppendSwitchIfNotNull("-v ", this.VirtualPath);
     commandLine.AppendSwitchIfNotNull("-p ", this.PhysicalPath);
     if (this.Updateable)
     {
         commandLine.AppendSwitch("-u");
     }
     if (this.Force)
     {
         commandLine.AppendSwitch("-f");
     }
     if (this.Clean)
     {
         commandLine.AppendSwitch("-c");
     }
     if (this.Debug)
     {
         commandLine.AppendSwitch("-d");
     }
     if (this.FixedNames)
     {
         commandLine.AppendSwitch("-fixednames");
     }
     commandLine.AppendSwitchIfNotNull("", this.TargetPath);
     if (this.AllowPartiallyTrustedCallers)
     {
         commandLine.AppendSwitch("-aptca");
     }
     if (this.DelaySign)
     {
         commandLine.AppendSwitch("-delaysign");
     }
     commandLine.AppendSwitchIfNotNull("-keyfile ", this.KeyFile);
     commandLine.AppendSwitchIfNotNull("-keycontainer ", this.KeyContainer);
 }
Exemplo n.º 18
0
        protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
        {
            commandLine.AppendSwitchIfNotNull("/target:", this.LicenseTarget.ItemSpec);
            foreach (ITaskItem item in this.Sources)
            {
                commandLine.AppendSwitchIfNotNull("/complist:", item.ItemSpec);
            }
            commandLine.AppendSwitchIfNotNull("/outdir:", this.OutputDirectory);
            if (this.ReferencedAssemblies != null)
            {
                foreach (ITaskItem item2 in this.ReferencedAssemblies)
                {
                    commandLine.AppendSwitchIfNotNull("/i:", item2.ItemSpec);
                }
            }
            commandLine.AppendWhenTrue("/nologo", base.Bag, "NoLogo");
            string str = this.LicenseTarget.ItemSpec + ".licenses";

            if (this.OutputDirectory != null)
            {
                str = Path.Combine(this.OutputDirectory, str);
            }
            this.OutputLicense = new TaskItem(str);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Adds commands for the tool being executed, that cannot be put in a response file.  
 /// </summary>
 /// <param name="commandLine">The CommandLineBuilderExtension to add the commands to</param>
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     AddStrongNameOptions(commandLine);
     base.AddCommandLineCommands(commandLine);
 }
Exemplo n.º 20
0
		public void TestWin32Resource ()
		{
			MCExtended mc = new MCExtended ();
			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();

			mc.Win32Resource = "A;B";
			mc.ARFC (c1);
			mc.ACLC (c2);
			
			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
		}
Exemplo n.º 21
0
		protected internal override void AddResponseFileCommands (CommandLineBuilderExtension commandLine)
		{
#if !NET_4_0
			//pre-MSBuild 2 targets don't support multi-targeting, so tell compiler to use 2.0 corlib
			commandLine.AppendSwitch ("/sdk:2");
#endif
			base.AddResponseFileCommands (commandLine);

			if (AdditionalLibPaths != null && AdditionalLibPaths.Length > 0)
				commandLine.AppendSwitchIfNotNull ("/lib:", AdditionalLibPaths, ",");

			if (Bag ["AllowUnsafeBlocks"] != null)
				if (AllowUnsafeBlocks)
					commandLine.AppendSwitch ("/unsafe+");
				else
					commandLine.AppendSwitch ("/unsafe-");

			//baseAddress
			
			if (Bag ["CheckForOverflowUnderflow"] != null)
				if (CheckForOverflowUnderflow)
					commandLine.AppendSwitch ("/checked+");
				else
					commandLine.AppendSwitch ("/checked-");

			if (!String.IsNullOrEmpty (DefineConstants)) {
				string [] defines = DefineConstants.Split (new char [] {';', ' '},
						StringSplitOptions.RemoveEmptyEntries);
				if (defines.Length > 0)
					commandLine.AppendSwitchIfNotNull ("/define:",
							String.Join (";", defines));
			}

			if (!String.IsNullOrEmpty (DisabledWarnings)) {
				string [] defines = DisabledWarnings.Split (new char [] {';', ' ', ','},
						StringSplitOptions.RemoveEmptyEntries);
				if (defines.Length > 0)
				    commandLine.AppendSwitchIfNotNull ("/nowarn:", defines, ";");
			}

			commandLine.AppendSwitchIfNotNull ("/doc:", DocumentationFile);

			//errorReport

			if (GenerateFullPaths)
				commandLine.AppendSwitch ("/fullpaths");

			commandLine.AppendSwitchIfNotNull ("/langversion:", LangVersion);

			commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);

			//moduleAssemblyName
			
			if (NoStandardLib)
				commandLine.AppendSwitch ("/nostdlib");

			//platform
			commandLine.AppendSwitchIfNotNull ("/platform:", Platform);
			//
			if (References != null)
				foreach (ITaskItem item in References) {
					string aliases = item.GetMetadata ("Aliases") ?? String.Empty;
					aliases = aliases.Trim ();
					if (aliases.Length > 0)
						commandLine.AppendSwitchIfNotNull ("/reference:" + aliases + "=", item.ItemSpec);
					else
						commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec);
				}

			if (ResponseFiles != null)
				foreach (ITaskItem item in ResponseFiles) 
					commandLine.AppendSwitchIfNotNull ("@", item.ItemSpec);

			if (Bag ["WarningLevel"] != null)
				commandLine.AppendSwitchIfNotNull ("/warn:", WarningLevel.ToString ());

			commandLine.AppendSwitchIfNotNull ("/warnaserror+:", WarningsAsErrors);

			commandLine.AppendSwitchIfNotNull ("/warnaserror-:", WarningsNotAsErrors);

			if (Win32Resource != null)
				commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
		}
Exemplo n.º 22
0
		public void TestTreatWarningsAsErrors2 ()
		{
			MCExtended mc = new MCExtended ();
			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();

			mc.TreatWarningsAsErrors = false;
			mc.ARFC (c1);
			mc.ACLC (c2);
			
			Assert.AreEqual ("/warnaserror-", c1.ToString (), "A1");
			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
		}
Exemplo n.º 23
0
		public void TestUtf8Output2 ()
		{
			MCExtended mc = new MCExtended ();
			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();

			mc.Utf8Output = false;
			mc.ARFC (c1);
			mc.ACLC (c2);
			
			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
		}
Exemplo n.º 24
0
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
#if !NET_4_0
            //pre-MSBuild 2 targets don't support multi-targeting, so tell compiler to use 2.0 corlib
            commandLine.AppendSwitch("/sdk:2");
#endif
            base.AddResponseFileCommands(commandLine);

            if (AdditionalLibPaths != null && AdditionalLibPaths.Length > 0)
            {
                commandLine.AppendSwitchIfNotNull("/lib:", AdditionalLibPaths, ",");
            }

            if (Bag ["AllowUnsafeBlocks"] != null)
            {
                if (AllowUnsafeBlocks)
                {
                    commandLine.AppendSwitch("/unsafe+");
                }
                else
                {
                    commandLine.AppendSwitch("/unsafe-");
                }
            }

            //baseAddress

            if (Bag ["CheckForOverflowUnderflow"] != null)
            {
                if (CheckForOverflowUnderflow)
                {
                    commandLine.AppendSwitch("/checked+");
                }
                else
                {
                    commandLine.AppendSwitch("/checked-");
                }
            }

            if (!String.IsNullOrEmpty(DefineConstants))
            {
                string [] defines = DefineConstants.Split(new char [] { ';', ' ' },
                                                          StringSplitOptions.RemoveEmptyEntries);
                if (defines.Length > 0)
                {
                    commandLine.AppendSwitchIfNotNull("/define:",
                                                      String.Join(";", defines));
                }
            }

            if (!String.IsNullOrEmpty(DisabledWarnings))
            {
                string [] defines = DisabledWarnings.Split(new char [] { ';', ' ', ',' },
                                                           StringSplitOptions.RemoveEmptyEntries);
                if (defines.Length > 0)
                {
                    commandLine.AppendSwitchIfNotNull("/nowarn:", defines, ";");
                }
            }

            commandLine.AppendSwitchIfNotNull("/doc:", DocumentationFile);

            //errorReport

            if (GenerateFullPaths)
            {
                commandLine.AppendSwitch("/fullpaths");
            }

            commandLine.AppendSwitchIfNotNull("/langversion:", LangVersion);

            commandLine.AppendSwitchIfNotNull("/main:", MainEntryPoint);

            //moduleAssemblyName

            if (NoStandardLib)
            {
                commandLine.AppendSwitch("/nostdlib");
            }

            //platform
            commandLine.AppendSwitchIfNotNull("/platform:", Platform);
            //
            if (References != null)
            {
                foreach (ITaskItem item in References)
                {
                    string aliases = item.GetMetadata("Aliases");
                    if (!string.IsNullOrEmpty(aliases))
                    {
                        AddAliasesReference(commandLine, aliases, item.ItemSpec);
                    }
                    else
                    {
                        commandLine.AppendSwitchIfNotNull("/reference:", item.ItemSpec);
                    }
                }
            }

            if (ResponseFiles != null)
            {
                foreach (ITaskItem item in ResponseFiles)
                {
                    commandLine.AppendSwitchIfNotNull("@", item.ItemSpec);
                }
            }

            if (Bag ["WarningLevel"] != null)
            {
                commandLine.AppendSwitchIfNotNull("/warn:", WarningLevel.ToString());
            }

            commandLine.AppendSwitchIfNotNull("/warnaserror+:", WarningsAsErrors);

            commandLine.AppendSwitchIfNotNull("/warnaserror-:", WarningsNotAsErrors);

            if (Win32Resource != null)
            {
                commandLine.AppendSwitchIfNotNull("/win32res:", Win32Resource);
            }
        }
Exemplo n.º 25
0
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     this.AddStrongNameOptions(commandLine);
     base.AddCommandLineCommands(commandLine);
 }
Exemplo n.º 26
0
        private void AddReferencesToCommandLine
            (
            CommandLineBuilderExtension commandLine
            )
        {
            if ((this.References == null) || (this.References.Length == 0))
            {
                return;
            }

            List<ITaskItem> references = new List<ITaskItem>(this.References.Length);
            List<ITaskItem> links = new List<ITaskItem>(this.References.Length);

            foreach (ITaskItem reference in this.References)
            {
                bool embed = MetadataConversionUtilities.TryConvertItemMetadataToBool
                    (
                        reference,
                        ItemMetadataNames.embedInteropTypes
                    );

                if (embed)
                {
                    links.Add(reference);
                }
                else
                {
                    references.Add(reference);
                }
            }

            if (links.Count > 0)
            {
                commandLine.AppendSwitchIfNotNull("/link:", links.ToArray(), ",");
            }

            if (references.Count > 0)
            {
                commandLine.AppendSwitchIfNotNull("/reference:", references.ToArray(), ",");
            }
        }
Exemplo n.º 27
0
		protected internal override void AddCommandLineCommands (
						 CommandLineBuilderExtension commandLine)
		{
			if (UseSourcePath)
				commandLine.AppendSwitch ("/useSourcePath");

			commandLine.AppendSwitch (String.Format ("/compile \"{0}{1}\"", SourceFile,
						OutputFile != null ? "," + OutputFile : ""));
		}
Exemplo n.º 28
0
        /// <summary>
        /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
        /// </summary>
        override protected internal void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            commandLine.AppendSwitchIfNotNull("/lib:", this.AdditionalLibPaths, ",");
            commandLine.AppendPlusOrMinusSwitch("/unsafe", this.Bag, "AllowUnsafeBlocks");
            commandLine.AppendPlusOrMinusSwitch("/checked", this.Bag, "CheckForOverflowUnderflow");
            commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", ';', ',');
            commandLine.AppendWhenTrue("/fullpaths", this.Bag, "GenerateFullPaths");
            commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion);
            commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName);
            commandLine.AppendSwitchIfNotNull("/pdb:", this.PdbFile);
            commandLine.AppendPlusOrMinusSwitch("/nostdlib", this.Bag, "NoStandardLib");
            commandLine.AppendSwitchIfNotNull("/platform:", this.PlatformWith32BitPreference);
            commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport);
            commandLine.AppendSwitchWithInteger("/warn:", this.Bag, "WarningLevel");
            commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile);
            commandLine.AppendSwitchIfNotNull("/baseaddress:", this.BaseAddress);
            commandLine.AppendSwitchUnquotedIfNotNull("/define:", this.GetDefineConstantsSwitch(this.DefineConstants));
            commandLine.AppendSwitchIfNotNull("/win32res:", this.Win32Resource);
            commandLine.AppendSwitchIfNotNull("/main:", this.MainEntryPoint);
            commandLine.AppendSwitchIfNotNull("/appconfig:", this.ApplicationConfiguration);
            commandLine.AppendWhenTrue("/errorendlocation", this.Bag, "ErrorEndLocation");
            commandLine.AppendSwitchIfNotNull("/preferreduilang:", this.PreferredUILang);
            commandLine.AppendPlusOrMinusSwitch("/highentropyva", this.Bag, "HighEntropyVA");

            // If not design time build and the globalSessionGuid property was set then add a -globalsessionguid:<guid>
            bool designTime = false;

            if (this.HostObject != null)
            {
                var csHost = this.HostObject as ICscHostObject;
                designTime = csHost.IsDesignTime();
            }
            if (!designTime)
            {
                if (!string.IsNullOrWhiteSpace(this.VsSessionGuid))
                {
                    commandLine.AppendSwitchIfNotNull("/sqmsessionguid:", this.VsSessionGuid);
                }
            }

            this.AddReferencesToCommandLine(commandLine);

            base.AddResponseFileCommands(commandLine);

            // This should come after the "TreatWarningsAsErrors" flag is processed (in managedcompiler.cs).
            // Because if TreatWarningsAsErrors=false, then we'll have a /warnaserror- on the command-line,
            // and then any specific warnings that should be treated as errors should be specified with
            // /warnaserror+:<list> after the /warnaserror- switch.  The order of the switches on the command-line
            // does matter.
            //
            // Note that
            //      /warnaserror+
            // is just shorthand for:
            //      /warnaserror+:<all possible warnings>
            //
            // Similarly,
            //      /warnaserror-
            // is just shorthand for:
            //      /warnaserror-:<all possible warnings>
            commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", ';', ',');
            commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", ';', ',');

            // It's a good idea for the response file to be the very last switch passed, just
            // from a predictability perspective.
            if (this.ResponseFiles != null)
            {
                foreach (ITaskItem response in this.ResponseFiles)
                {
                    commandLine.AppendSwitchIfNotNull("@", response.ItemSpec);
                }
            }
        }
Exemplo n.º 29
0
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            commandLine.AppendSwitchIfNotNull("/baseaddress:", this.GetBaseAddressInHex());
            commandLine.AppendSwitchIfNotNull("/libpath:", base.AdditionalLibPaths, ",");
            commandLine.AppendSwitchIfNotNull("/imports:", this.Imports, ",");
            commandLine.AppendPlusOrMinusSwitch("/doc", base.Bag, "GenerateDocumentation");
            commandLine.AppendSwitchIfNotNull("/optioncompare:", this.OptionCompare);
            commandLine.AppendPlusOrMinusSwitch("/optionexplicit", base.Bag, "OptionExplicit");
            object obj2 = base.Bag["OptionStrict"];

            if ((obj2 != null) ? ((bool)obj2) : false)
            {
                commandLine.AppendSwitch("/optionstrict+");
            }
            else
            {
                commandLine.AppendSwitch("/optionstrict:custom");
            }
            commandLine.AppendSwitchIfNotNull("/optionstrict:", this.OptionStrictType);
            commandLine.AppendWhenTrue("/nowarn", base.Bag, "NoWarnings");
            commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", new char[] { ';', ',' });
            commandLine.AppendPlusOrMinusSwitch("/optioninfer", base.Bag, "OptionInfer");
            commandLine.AppendWhenTrue("/nostdlib", base.Bag, "NoStandardLib");
            commandLine.AppendWhenTrue("/novbruntimeref", base.Bag, "NoVBRuntimeReference");
            commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport);
            commandLine.AppendSwitchIfNotNull("/platform:", this.Platform);
            commandLine.AppendPlusOrMinusSwitch("/removeintchecks", base.Bag, "RemoveIntegerChecks");
            commandLine.AppendSwitchIfNotNull("/rootnamespace:", this.RootNamespace);
            commandLine.AppendSwitchIfNotNull("/sdkpath:", this.SdkPath);
            commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion);
            commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName);
            commandLine.AppendWhenTrue("/netcf", base.Bag, "TargetCompactFramework");
            if (this.VBRuntime != null)
            {
                string vBRuntime = this.VBRuntime;
                if (string.Compare(vBRuntime, "EMBED", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    commandLine.AppendSwitch("/vbruntime*");
                }
                else if (string.Compare(vBRuntime, "NONE", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    commandLine.AppendSwitch("/vbruntime-");
                }
                else if (string.Compare(vBRuntime, "DEFAULT", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    commandLine.AppendSwitch("/vbruntime+");
                }
                else
                {
                    commandLine.AppendSwitchIfNotNull("/vbruntime:", vBRuntime);
                }
            }
            if ((this.Verbosity != null) && ((string.Compare(this.Verbosity, "quiet", StringComparison.OrdinalIgnoreCase) == 0) || (string.Compare(this.Verbosity, "verbose", StringComparison.OrdinalIgnoreCase) == 0)))
            {
                commandLine.AppendSwitchIfNotNull("/", this.Verbosity);
            }
            commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile);
            commandLine.AppendSwitchUnquotedIfNotNull("/define:", GetDefineConstantsSwitch(base.DefineConstants));
            this.AddReferencesToCommandLine(commandLine);
            commandLine.AppendSwitchIfNotNull("/win32resource:", base.Win32Resource);
            if (string.Compare("Sub Main", base.MainEntryPoint, StringComparison.OrdinalIgnoreCase) != 0)
            {
                commandLine.AppendSwitchIfNotNull("/main:", base.MainEntryPoint);
            }
            base.AddResponseFileCommands(commandLine);
            commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", new char[] { ';', ',' });
            commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", new char[] { ';', ',' });
            if (base.ResponseFiles != null)
            {
                foreach (ITaskItem item in base.ResponseFiles)
                {
                    commandLine.AppendSwitchIfNotNull("@", item.ItemSpec);
                }
            }
        }
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 31
0
        protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
        {
            base.AddCommandLineCommands(commandLine);

            commandLine.AppendPlusOrMinusSwitch("/nostdlib", NoStandardLib);
        }
Exemplo n.º 32
0
        protected override string GenerateCommandLineCommands()
        {
            CommandLineBuilderExtension extension = new CommandLineBuilderExtension();
            bool flag = false;

            try
            {
                if (this.SerializationAssembly == null)
                {
                    this.SerializationAssembly = new TaskItem[] { new TaskItem(this.SerializationAssemblyPath) };
                }
                extension.AppendSwitchIfNotNull("/assembly:", this.AssemblyFullPath);
                extension.AppendWhenTrue("/proxytypes", base.Bag, "UseProxyTypes");
                if (this.References != null)
                {
                    foreach (string str in this.References)
                    {
                        extension.AppendSwitchIfNotNull("/reference:", str);
                    }
                }
                if (this.Types != null)
                {
                    foreach (string str2 in this.Types)
                    {
                        extension.AppendSwitchIfNotNull("/type:", str2);
                    }
                }
                if (this.KeyFile != null)
                {
                    extension.AppendNestedSwitch("/compiler:", "/keyfile:", this.KeyFile);
                }
                else if (this.KeyContainer != null)
                {
                    extension.AppendNestedSwitch("/compiler:", "/keycontainer:", this.KeyContainer);
                }
                extension.AppendPlusOrMinusSwitch("/compiler:/delaysign", base.Bag, "DelaySign");
                if (this.Platform != null)
                {
                    extension.AppendNestedSwitch("/compiler:", "/platform:", this.Platform);
                }
                flag = File.Exists(this.SerializationAssemblyPath);
            }
            catch (Exception exception)
            {
                if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception))
                {
                    throw;
                }
            }
            if (flag)
            {
                try
                {
                    File.Delete(this.SerializationAssemblyPath);
                }
                catch (UnauthorizedAccessException exception2)
                {
                    base.Log.LogErrorWithCodeFromResources("SGen.CouldNotDeleteSerializer", new object[] { this.SerializationAssemblyPath, exception2.Message });
                }
                catch (IOException exception3)
                {
                    base.Log.LogErrorWithCodeFromResources("SGen.CouldNotDeleteSerializer", new object[] { this.SerializationAssemblyPath, exception3.Message });
                }
            }
            return(extension.ToString());
        }
Exemplo n.º 33
0
        /// <summary>
        /// Adds options involving strong name signing -- syntax is the same between 
        /// AxImp and TlbImp
        /// </summary>
        /// <param name="commandLine">The command line to add options to</param>
        private void AddStrongNameOptions(CommandLineBuilderExtension commandLine)
        {
            commandLine.AppendWhenTrue("/delaysign", Bag, "DelaySign");

            // If we're delay-signing, we only need the public key, but if we use the /publickey
            // switch, it will consume the entire key file, assume that's just the public key, and 
            // throw an error.
            // 
            // So use /publickey if that's all our KeyFile contains, but KeyFile otherwise. 
            if (_delaySigningAndKeyFileOnlyContainsPublicKey)
            {
                commandLine.AppendSwitchIfNotNull("/publickey:", KeyFile);
            }
            else
            {
                commandLine.AppendSwitchIfNotNull("/keyfile:", KeyFile);
            }

            commandLine.AppendSwitchIfNotNull("/keycontainer:", KeyContainer);
        }
Exemplo n.º 34
0
 private void AddStrongNameOptions(CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendWhenTrue("/delaysign", base.Bag, "DelaySign");
     commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
     commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
 }
Exemplo n.º 35
0
        /// <summary>
        /// Generates response file with arguments for lc.exe
        /// </summary>
        /// <param name="commandLine">command line builder class to add arguments to the response file</param>
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            commandLine.AppendSwitchIfNotNull("/target:", LicenseTarget.ItemSpec);

            foreach (ITaskItem item in Sources)
            {
                commandLine.AppendSwitchIfNotNull("/complist:", item.ItemSpec);
            }

            commandLine.AppendSwitchIfNotNull("/outdir:", OutputDirectory);

            if (ReferencedAssemblies != null)
            {
                foreach (ITaskItem item in ReferencedAssemblies)
                {
                    commandLine.AppendSwitchIfNotNull("/i:", item.ItemSpec);
                }
            }

            commandLine.AppendWhenTrue("/nologo", Bag, "NoLogo");

            // generate the output file name
            string outputPath = LicenseTarget.ItemSpec + ".licenses";

            if (OutputDirectory != null)
                outputPath = Path.Combine(OutputDirectory, outputPath);

            OutputLicense = new TaskItem(outputPath);
        }
Exemplo n.º 36
0
        /// <summary>
        /// The C# compiler (starting with Whidbey) supports assembly aliasing for references.
        /// See spec at http://devdiv/spectool/Documents/Whidbey/VCSharp/Design%20Time/M3%20DCRs/DCR%20Assembly%20aliases.doc.
        /// This method handles the necessary work of looking at the "Aliases" attribute on
        /// the incoming "References" items, and making sure to generate the correct
        /// command-line on csc.exe.  The syntax for aliasing a reference is:
        ///     csc.exe /reference:Foo=System.Xml.dll
        ///
        /// The "Aliases" attribute on the "References" items is actually a comma-separated
        /// list of aliases, and if any of the aliases specified is the string "global",
        /// then we add that reference to the command-line without an alias.
        /// </summary>
        /// <param name="commandLine"></param>
        private void AddReferencesToCommandLine
        (
            CommandLineBuilderExtension commandLine
        )
        {
            // If there were no references passed in, don't add any /reference: switches
            // on the command-line.
            if ((this.References == null) || (this.References.Length == 0))
            {
                return;
            }

            // Loop through all the references passed in.  We'll be adding separate
            // /reference: switches for each reference, and in some cases even multiple
            // /reference: switches per reference.
            foreach (ITaskItem reference in this.References)
            {
                // See if there was an "Alias" attribute on the reference.
                string aliasString = reference.GetMetadata(ItemMetadataNames.aliases);


                string switchName = "/reference:";
                bool   embed      = MetadataConversionUtilities.TryConvertItemMetadataToBool
                                    (
                    reference,
                    ItemMetadataNames.embedInteropTypes
                                    );

                if (embed == true)
                {
                    switchName = "/link:";
                }

                if ((aliasString == null) || (aliasString.Length == 0))
                {
                    // If there was no "Alias" attribute, just add this as a global reference.
                    commandLine.AppendSwitchIfNotNull(switchName, reference.ItemSpec);
                }
                else
                {
                    // If there was an "Alias" attribute, it contains a comma-separated list
                    // of aliases to use for this reference.  For each one of those aliases,
                    // we're going to add a separate /reference: switch to the csc.exe
                    // command-line
                    string[] aliases = aliasString.Split(',');

                    foreach (string alias in aliases)
                    {
                        // Trim whitespace.
                        string trimmedAlias = alias.Trim();

                        if (alias.Length == 0)
                        {
                            continue;
                        }

                        // The alias should be a valid C# identifier.  Therefore it cannot
                        // contain comma, space, semicolon, or double-quote.  Let's check for
                        // the existence of those characters right here, and bail immediately
                        // if any are present.  There are a whole bunch of other characters
                        // that are not allowed in a C# identifier, but we'll just let csc.exe
                        // error out on those.  The ones we're checking for here are the ones
                        // that could seriously interfere with the command-line parsing or could
                        // allow parameter injection.
                        if (trimmedAlias.IndexOfAny(new char[] { ',', ' ', ';', '"' }) != -1)
                        {
                            ErrorUtilities.VerifyThrowArgument
                            (
                                false,
                                "Csc.AssemblyAliasContainsIllegalCharacters",
                                reference.ItemSpec,
                                trimmedAlias
                            );
                        }

                        // The alias called "global" is special.  It means that we don't
                        // give it an alias on the command-line.
                        if (String.Compare("global", trimmedAlias, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            commandLine.AppendSwitchIfNotNull(switchName, reference.ItemSpec);
                        }
                        else
                        {
                            // We have a valid (and explicit) alias for this reference.  Add
                            // it to the command-line using the syntax:
                            //      /reference:Foo=System.Xml.dll
                            commandLine.AppendSwitchAliased(switchName, trimmedAlias, reference.ItemSpec);
                        }
                    }
                }
            }
        }
Exemplo n.º 37
0
        /// <summary>
        /// Looks at all the parameters that have been set, and builds up the string
        /// containing all the command-line switches.
        /// </summary>
        /// <param name="commandLine"></param>
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            commandLine.AppendSwitchIfNotNull("/baseaddress:", this.GetBaseAddressInHex());
            commandLine.AppendSwitchIfNotNull("/libpath:", this.AdditionalLibPaths, ",");
            commandLine.AppendSwitchIfNotNull("/imports:", this.Imports, ",");
            // Make sure this /doc+ switch comes *before* the /doc:<file> switch (which is handled in the
            // ManagedCompiler.cs base class).  /doc+ is really just an alias for /doc:<assemblyname>.xml,
            // and the last /doc switch on the command-line wins.  If the user provided a specific doc filename,
            // we want that one to win.
            commandLine.AppendPlusOrMinusSwitch("/doc", this.Bag, "GenerateDocumentation");
            commandLine.AppendSwitchIfNotNull("/optioncompare:", this.OptionCompare);
            commandLine.AppendPlusOrMinusSwitch("/optionexplicit", this.Bag, "OptionExplicit");
            // Make sure this /optionstrict+ switch appears *before* the /optionstrict:xxxx switch below

            /* In Orcas a change was made that set Option Strict-, whenever this.DisabledWarnings was
             * empty.  That was clearly the wrong thing to do and we found it when we had a project with all the warning configuration 
             * entries set to WARNING.  Because this.DisabledWarnings was empty in that case we would end up sending /OptionStrict- 
             * effectively silencing all the warnings that had been selected.
             * 
             * Now what we do is:
             *  If option strict+ is specified, that trumps everything and we just set option strict+ 
             *  Otherwise, just set option strict:custom.
             *  You may wonder why we don't try to set Option Strict-  The reason is that Option Strict- just implies a certain
             *  set of warnings that should be disabled (there's ten of them today)  You get the same effect by sending 
             *  option strict:custom on along with the correct list of disabled warnings.
             *  Rather than make this code know the current set of disabled warnings that comprise Option strict-, we just send
             *  option strict:custom on with the understanding that we'll get the same behavior as option strict- since we are passing
             *  the /nowarn line on that contains all the warnings OptionStrict- would disable anyway. The IDE knows what they are
             *  and puts them in the project file so we are good.  And by not making this code aware of which warnings comprise
             *  Option Strict-, we have one less place we have to keep up to date in terms of what comprises option strict-
             */

            // Decide whether we are Option Strict+ or Option Strict:custom
            object optionStrictSetting = this.Bag["OptionStrict"];
            bool optionStrict = optionStrictSetting != null ? (bool)optionStrictSetting : false;
            if (optionStrict)
            {
                commandLine.AppendSwitch("/optionstrict+");
            }
            else // OptionStrict+ wasn't specified so use :custom.
            {
                commandLine.AppendSwitch("/optionstrict:custom");
            }

            commandLine.AppendSwitchIfNotNull("/optionstrict:", this.OptionStrictType);
            commandLine.AppendWhenTrue("/nowarn", this.Bag, "NoWarnings");
            commandLine.AppendSwitchWithSplitting("/nowarn:", this.DisabledWarnings, ",", ';', ',');
            commandLine.AppendPlusOrMinusSwitch("/optioninfer", this.Bag, "OptionInfer");
            commandLine.AppendWhenTrue("/nostdlib", this.Bag, "NoStandardLib");
            commandLine.AppendWhenTrue("/novbruntimeref", this.Bag, "NoVBRuntimeReference");
            commandLine.AppendSwitchIfNotNull("/errorreport:", this.ErrorReport);
            commandLine.AppendSwitchIfNotNull("/platform:", this.PlatformWith32BitPreference);
            commandLine.AppendPlusOrMinusSwitch("/removeintchecks", this.Bag, "RemoveIntegerChecks");
            commandLine.AppendSwitchIfNotNull("/rootnamespace:", this.RootNamespace);
            commandLine.AppendSwitchIfNotNull("/sdkpath:", this.SdkPath);
            commandLine.AppendSwitchIfNotNull("/langversion:", this.LangVersion);
            commandLine.AppendSwitchIfNotNull("/moduleassemblyname:", this.ModuleAssemblyName);
            commandLine.AppendWhenTrue("/netcf", this.Bag, "TargetCompactFramework");
            commandLine.AppendSwitchIfNotNull("/preferreduilang:", this.PreferredUILang);
            commandLine.AppendPlusOrMinusSwitch("/highentropyva", this.Bag, "HighEntropyVA");

            if (0 == String.Compare(this.VBRuntimePath, this.VBRuntime, StringComparison.OrdinalIgnoreCase))
            {
                commandLine.AppendSwitchIfNotNull("/vbruntime:", this.VBRuntimePath);
            }
            else if (this.VBRuntime != null)
            {
                string vbRuntimeSwitch = this.VBRuntime;
                if (0 == String.Compare(vbRuntimeSwitch, "EMBED", StringComparison.OrdinalIgnoreCase))
                {
                    commandLine.AppendSwitch("/vbruntime*");
                }
                else if (0 == String.Compare(vbRuntimeSwitch, "NONE", StringComparison.OrdinalIgnoreCase))
                {
                    commandLine.AppendSwitch("/vbruntime-");
                }
                else if (0 == String.Compare(vbRuntimeSwitch, "DEFAULT", StringComparison.OrdinalIgnoreCase))
                {
                    commandLine.AppendSwitch("/vbruntime+");
                }
                else
                {
                    commandLine.AppendSwitchIfNotNull("/vbruntime:", vbRuntimeSwitch);
                }
            }


            // Verbosity
            if (
                   (this.Verbosity != null) &&

                   (
                      (0 == String.Compare(this.Verbosity, "quiet", StringComparison.OrdinalIgnoreCase)) ||
                      (0 == String.Compare(this.Verbosity, "verbose", StringComparison.OrdinalIgnoreCase))
                   )
                )
            {
                commandLine.AppendSwitchIfNotNull("/", this.Verbosity);
            }

            commandLine.AppendSwitchIfNotNull("/doc:", this.DocumentationFile);
            commandLine.AppendSwitchUnquotedIfNotNull("/define:", Vbc.GetDefineConstantsSwitch(this.DefineConstants));
            AddReferencesToCommandLine(commandLine);
            commandLine.AppendSwitchIfNotNull("/win32resource:", this.Win32Resource);

            // Special case for "Sub Main"
            if (0 != String.Compare("Sub Main", this.MainEntryPoint, StringComparison.OrdinalIgnoreCase))
            {
                commandLine.AppendSwitchIfNotNull("/main:", this.MainEntryPoint);
            }

            base.AddResponseFileCommands(commandLine);

            // This should come after the "TreatWarningsAsErrors" flag is processed (in managedcompiler.cs).
            // Because if TreatWarningsAsErrors=false, then we'll have a /warnaserror- on the command-line,
            // and then any specific warnings that should be treated as errors should be specified with
            // /warnaserror+:<list> after the /warnaserror- switch.  The order of the switches on the command-line
            // does matter.
            //
            // Note that
            //      /warnaserror+
            // is just shorthand for:
            //      /warnaserror+:<all possible warnings>
            //
            // Similarly,
            //      /warnaserror-
            // is just shorthand for:
            //      /warnaserror-:<all possible warnings>
            commandLine.AppendSwitchWithSplitting("/warnaserror+:", this.WarningsAsErrors, ",", ';', ',');
            commandLine.AppendSwitchWithSplitting("/warnaserror-:", this.WarningsNotAsErrors, ",", ';', ',');

            // If not design time build and the globalSessionGuid property was set then add a -globalsessionguid:<guid>
            bool designTime = false;
            if (this.HostObject != null)
            {
                var vbHost = this.HostObject as IVbcHostObject;
                designTime = vbHost.IsDesignTime();
            }
            if (!designTime)
            {
                if (!string.IsNullOrWhiteSpace(this.VsSessionGuid))
                {
                    commandLine.AppendSwitchIfNotNull("/sqmsessionguid:", this.VsSessionGuid);
                }
            }

            // It's a good idea for the response file to be the very last switch passed, just 
            // from a predictability perspective.
            if (this.ResponseFiles != null)
            {
                foreach (ITaskItem response in this.ResponseFiles)
                {
                    commandLine.AppendSwitchIfNotNull("@", response.ItemSpec);
                }
            }
        }
Exemplo n.º 38
0
 protected internal override void AddResponseFileCommands(
     CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendSwitchIfNotNull("/algid:", AlgorithmId);
     commandLine.AppendSwitchIfNotNull("/baseaddress:", BaseAddress);
     commandLine.AppendSwitchIfNotNull("/company:", CompanyName);
     commandLine.AppendSwitchIfNotNull("/configuration:", Configuration);
     commandLine.AppendSwitchIfNotNull("/culture:", Culture);
     commandLine.AppendSwitchIfNotNull("/copyright:", Copyright);
     if (Bag ["DelaySign"] != null)
     {
         if (DelaySign)
         {
             commandLine.AppendSwitch("/delaysign+");
         }
         else
         {
             commandLine.AppendSwitch("/delaysign-");
         }
     }
     commandLine.AppendSwitchIfNotNull("/description:", Description);
     if (EmbedResources != null)
     {
         foreach (ITaskItem item in EmbedResources)
         {
             commandLine.AppendSwitchIfNotNull("/embed:", item.ItemSpec);
         }
     }
     commandLine.AppendSwitchIfNotNull("/evidence:", EvidenceFile);
     commandLine.AppendSwitchIfNotNull("/fileversion:", FileVersion);
     commandLine.AppendSwitchIfNotNull("/flags:", Flags);
     if (GenerateFullPaths)
     {
         commandLine.AppendSwitch("/fullpaths");
     }
     commandLine.AppendSwitchIfNotNull("/keyname:", KeyContainer);
     commandLine.AppendSwitchIfNotNull("/keyfile:", KeyFile);
     if (LinkResources != null)
     {
         foreach (ITaskItem item in LinkResources)
         {
             commandLine.AppendSwitchIfNotNull("/link:", item.ItemSpec);
         }
     }
     commandLine.AppendSwitchIfNotNull("/main:", MainEntryPoint);
     if (OutputAssembly != null)
     {
         commandLine.AppendSwitchIfNotNull("/out:", OutputAssembly.ItemSpec);
     }
     //platform
     commandLine.AppendSwitchIfNotNull("/product:", ProductName);
     commandLine.AppendSwitchIfNotNull("/productversion:", ProductVersion);
     if (ResponseFiles != null)
     {
         foreach (string s in ResponseFiles)
         {
             commandLine.AppendFileNameIfNotNull(String.Format("@{0}", s));
         }
     }
     if (SourceModules != null)
     {
         foreach (ITaskItem item in SourceModules)
         {
             commandLine.AppendFileNameIfNotNull(item.ItemSpec);
         }
     }
     commandLine.AppendSwitchIfNotNull("/target:", TargetType);
     commandLine.AppendSwitchIfNotNull("/template:", TemplateFile);
     commandLine.AppendSwitchIfNotNull("/title:", Title);
     commandLine.AppendSwitchIfNotNull("/trademark:", Trademark);
     commandLine.AppendSwitchIfNotNull("/version:", Version);
     commandLine.AppendSwitchIfNotNull("/win32icon:", Win32Icon);
     commandLine.AppendSwitchIfNotNull("/win32res:", Win32Resource);
 }
Exemplo n.º 39
0
        protected internal override void AddResponseFileCommands(
            CommandLineBuilderExtension commandLine)
        {
            base.AddResponseFileCommands(commandLine);

            commandLine.AppendSwitchIfNotNull("/libpath:", AdditionalLibPaths, ",");

            commandLine.AppendSwitchIfNotNull("/baseaddress:", BaseAddress);

            if (DefineConstants != null)
            {
                commandLine.AppendSwitchUnquotedIfNotNull("/define:",
                                                          String.Format("\"{0}\"", EscapeDoubleQuotes(DefineConstants)));
            }

            // DisabledWarnings

            commandLine.AppendSwitchIfNotNull("/doc:", DocumentationFile);

            // ErrorReport

            // GenerateDocumentation

            if (Imports != null)
            {
                foreach (ITaskItem item in Imports)
                {
                    commandLine.AppendSwitchIfNotNull("/imports:", item.ItemSpec);
                }
            }

            commandLine.AppendSwitchIfNotNull("/main:", MainEntryPoint);

            // NoStandardLib

            if (NoWarnings)
            {
                commandLine.AppendSwitch("/nowarn");
            }

            commandLine.AppendSwitchIfNotNull("/optioncompare:", OptionCompare);

            if (Bag ["OptionExplicit"] != null)
            {
                if (OptionExplicit)
                {
                    commandLine.AppendSwitch("/optionexplicit+");
                }
                else
                {
                    commandLine.AppendSwitch("/optionexplicit-");
                }
            }

            if (Bag ["OptionStrict"] != null)
            {
                if (OptionStrict)
                {
                    commandLine.AppendSwitch("/optionstrict+");
                }
                else
                {
                    commandLine.AppendSwitch("/optionstrict-");
                }
            }

            // OptionStrictType

            // Platform

            if (References != null)
            {
                foreach (ITaskItem item in References)
                {
                    commandLine.AppendSwitchIfNotNull("/reference:", item.ItemSpec);
                }
            }

            if (Bag ["RemoveIntegerChecks"] != null)
            {
                if (RemoveIntegerChecks)
                {
                    commandLine.AppendSwitch("/removeintchecks+");
                }
                else
                {
                    commandLine.AppendSwitch("/removeintchecks-");
                }
            }

            if (ResponseFiles != null)
            {
                foreach (ITaskItem item in ResponseFiles)
                {
                    commandLine.AppendFileNameIfNotNull(String.Format("@{0}", item.ItemSpec));
                }
            }

            commandLine.AppendSwitchIfNotNull("/rootnamespace:", RootNamespace);

            commandLine.AppendSwitchIfNotNull("/sdkpath:", SdkPath);

            // TargetCompactFramework

            // Verbosity

            // WarningsAsErrors

            // WarningsNotAsErrors
        }
Exemplo n.º 40
0
        /// <summary>
        /// Returns a string with those switches and other information that can't go into a response file and
        /// must go directly onto the command line.
        /// Called after ValidateParameters and SkipTaskExecution
        /// </summary>
        override protected string GenerateCommandLineCommands()
        {
            CommandLineBuilderExtension commandLineBuilder = new CommandLineBuilderExtension();
            bool serializationAssemblyPathExists           = false;

            try
            {
                if (SerializationAssembly == null)
                {
                    Debug.Assert(ShouldGenerateSerializer, "GenerateCommandLineCommands() should not be called if ShouldGenerateSerializer is true and SerializationAssembly is null.");

                    SerializationAssembly = new TaskItem[] { new TaskItem(SerializationAssemblyPath) };
                }

                // Add the assembly switch
                commandLineBuilder.AppendSwitchIfNotNull("/assembly:", AssemblyFullPath);

                commandLineBuilder.AppendWhenTrue("/proxytypes", Bag, "UseProxyTypes");

                //add the keep switch
                commandLineBuilder.AppendWhenTrue("/keep", Bag, "UseKeep");

                // Append the references, if any.
                if (References != null)
                {
                    foreach (string reference in References)
                    {
                        commandLineBuilder.AppendSwitchIfNotNull("/reference:", reference);
                    }
                }

                //Append the Types to the command line, if any.
                if (Types != null)
                {
                    foreach (string type in Types)
                    {
                        commandLineBuilder.AppendSwitchIfNotNull("/type:", type);
                    }
                }

                // The arguments to the "/compiler" switch are themselves switches to be passed to
                // the compiler when generating the serialization assembly.

                // Add the compiler command switches for strong naming on the serialization assembly
                if (KeyFile != null)
                {
                    commandLineBuilder.AppendNestedSwitch("/compiler:", "/keyfile:", KeyFile);
                }
                else if (KeyContainer != null)
                {
                    commandLineBuilder.AppendNestedSwitch("/compiler:", "/keycontainer:", KeyContainer);
                }

                commandLineBuilder.AppendPlusOrMinusSwitch("/compiler:/delaysign", Bag, "DelaySign");

                // Add the Platform switch to the compiler.
                if (Platform != null)
                {
                    commandLineBuilder.AppendNestedSwitch("/compiler:", "/platform:", Platform);
                }

                serializationAssemblyPathExists = File.Exists(SerializationAssemblyPath);
            }
            catch (Exception e) when(ExceptionHandling.IsIoRelatedException(e))
            {
                // Ignore the expected exceptions because they have already been logged
            }

            // Delete the assembly if it already exists.
            if (serializationAssemblyPathExists)
            {
                try
                {
                    File.Delete(SerializationAssemblyPath);
                }
                // Of all of the exceptions that can be thrown on a File.Delete, the only ones we need to
                // be immediately concerned with are the UnauthorizedAccessException and the IOException
                // (file is in use exception).  We need to make sure that the assembly is gone before we
                // try to produce a new one because it is possible that after some changes were made to the
                // base assembly, there will, in fact, not be a serialization assembly produced.  We cannot
                // leave the earlier produced assembly around to be propagated by later processes.
                catch (UnauthorizedAccessException e)
                {
                    Log.LogErrorWithCodeFromResources("SGen.CouldNotDeleteSerializer", SerializationAssemblyPath, e.Message);
                }
                catch (IOException e)
                {
                    Log.LogErrorWithCodeFromResources("SGen.CouldNotDeleteSerializer", SerializationAssemblyPath, e.Message);
                }
                // The DirectoryNotFoundException is safely ignorable since that means that there is no
                // existing serialization assembly.  This would be extremely unlikely anyway because we
                // found the serializer just a couple of milliseconds ago.
            }

            return(commandLineBuilder.ToString());
        }
Exemplo n.º 41
0
        /// <summary>
        /// Adds the arguments for cmd.exe
        /// </summary>
        /// <param name="commandLine">command line builder class to add arguments to</param>
        protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
        {
            // Create the batch file now,
            // so we have the file name for the cmd.exe command line
            CreateTemporaryBatchFile();

            string batchFileForCommandLine = _batchFile;
            commandLine.AppendSwitch("/Q");      // echo off
            commandLine.AppendSwitch("/C");      // run then terminate

            // If for some crazy reason the path has a & character and a space in it
            // then get the short path of the temp path, which should not have spaces in it
            // and then escape the &
            if (batchFileForCommandLine.Contains("&") && !batchFileForCommandLine.Contains("^&"))
            {
                batchFileForCommandLine = NativeMethodsShared.GetShortFilePath(batchFileForCommandLine);
                batchFileForCommandLine = batchFileForCommandLine.Replace("&", "^&");
            }

            commandLine.AppendFileNameIfNotNull(batchFileForCommandLine);
        }
 protected internal virtual void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
 {
 }
Exemplo n.º 43
0
		protected override string GenerateCommandLineCommands ()
		{
			CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
			AddCommandLineCommands (clbe);
			return clbe.ToString ();
		}
 protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
 {
     commandLine.AppendWhenTrue("/noconfig", base.Bag, "NoConfig");
 }
Exemplo n.º 45
0
		protected internal override void AddResponseFileCommands (
				CommandLineBuilderExtension commandLine )
		{
			base.AddResponseFileCommands (commandLine);

			commandLine.AppendSwitchIfNotNull ("/libpath:", AdditionalLibPaths, ",");

			commandLine.AppendSwitchIfNotNull ("/baseaddress:", BaseAddress);

			if (DefineConstants != null)
				commandLine.AppendSwitchUnquotedIfNotNull ("/define:",
						String.Format ("\"{0}\"", EscapeDoubleQuotes (DefineConstants)));

			// DisabledWarnings

			commandLine.AppendSwitchIfNotNull ("/doc:", DocumentationFile);

			// ErrorReport
			
			// GenerateDocumentation
			
			if (Imports != null)
				foreach (ITaskItem item in Imports)
					commandLine.AppendSwitchIfNotNull ("/imports:", item.ItemSpec);
			
			commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);

			// NoStandardLib
			if (Bag ["NoStandardLib"] != null && NoStandardLib)
				commandLine.AppendSwitch ("/nostdlib");
			
			if (NoWarnings)
				commandLine.AppendSwitch ("/nowarn");

			commandLine.AppendSwitchIfNotNull ("/optioncompare:", OptionCompare);

			if (Bag ["OptionExplicit"] != null)
				if (OptionExplicit)
					commandLine.AppendSwitch ("/optionexplicit+");
				else
					commandLine.AppendSwitch ("/optionexplicit-");

			if (Bag ["OptionStrict"] != null)
				if (OptionStrict)
					commandLine.AppendSwitch ("/optionstrict+");
				else
					commandLine.AppendSwitch ("/optionstrict-");

			if (Bag ["OptionInfer"] != null)
				if (OptionInfer)
					commandLine.AppendSwitch ("/optioninfer+");
				else
					commandLine.AppendSwitch ("/optioninfer-");

			// OptionStrictType
			
			// Platform
			
			if (References != null)
				foreach (ITaskItem item in References)
					commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec);
	
			if (Bag ["RemoveIntegerChecks"] != null)
				if (RemoveIntegerChecks)
					commandLine.AppendSwitch ("/removeintchecks+");
				else
					commandLine.AppendSwitch ("/removeintchecks-");

			if (ResponseFiles != null)
				foreach (ITaskItem item in ResponseFiles)
					commandLine.AppendFileNameIfNotNull (String.Format ("@{0}", item.ItemSpec));

			commandLine.AppendSwitchIfNotNull ("/rootnamespace:", RootNamespace);

			commandLine.AppendSwitchIfNotNull ("/sdkpath:", SdkPath);

			// TargetCompactFramework

			if (String.Compare (VBRuntime, "Embed", StringComparison.OrdinalIgnoreCase) == 0) 
				commandLine.AppendSwitch ("/vbruntime*");
			
			// Verbosity

			// WarningsAsErrors

			// WarningsNotAsErrors

		}
Exemplo n.º 46
0
        /// <summary>
        /// Fills the provided CommandLineBuilderExtension with those switches and other information that can go into a response file.
        /// </summary>
        protected internal override void AddResponseFileCommands(CommandLineBuilderExtension commandLine)
        {
            // If outputAssembly is not specified, then an "/out: <name>" option won't be added to
            // overwrite the one resulting from the OutputAssembly member of the CompilerParameters class.
            // In that case, we should set the outputAssembly member based on the first source file.
            if (
                (OutputAssembly == null) &&
                (Sources != null) &&
                (Sources.Length > 0) &&
                (this.ResponseFiles == null)        // The response file may already have a /out: switch in it, so don't try to be smart here.
                )
            {
                try
                {
                    OutputAssembly = new TaskItem(Path.GetFileNameWithoutExtension(Sources[0].ItemSpec));
                }
                catch (ArgumentException e)
                {
                    throw new ArgumentException(e.Message, "Sources");
                }
                if (String.Compare(TargetType, "library", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    OutputAssembly.ItemSpec += ".dll";
                }
                else if (String.Compare(TargetType, "module", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    OutputAssembly.ItemSpec += ".netmodule";
                }
                else
                {
                    OutputAssembly.ItemSpec += ".exe";
                }
            }

            commandLine.AppendSwitchIfNotNull("/addmodule:", this.AddModules, ",");
            commandLine.AppendSwitchWithInteger("/codepage:", this.Bag, "CodePage");

            ConfigureDebugProperties();

            // The "DebugType" parameter should be processed after the "EmitDebugInformation" parameter
            // because it's more specific.  Order matters on the command-line, and the last one wins.
            // /debug+ is just a shorthand for /debug:full.  And /debug- is just a shorthand for /debug:none.

            commandLine.AppendPlusOrMinusSwitch("/debug", this.Bag, "EmitDebugInformation");
            commandLine.AppendSwitchIfNotNull("/debug:", this.DebugType);

            commandLine.AppendPlusOrMinusSwitch("/delaysign", this.Bag, "DelaySign");

            commandLine.AppendSwitchWithInteger("/filealign:", this.Bag, "FileAlignment");
            commandLine.AppendSwitchIfNotNull("/keycontainer:", this.KeyContainer);
            commandLine.AppendSwitchIfNotNull("/keyfile:", this.KeyFile);
            // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject.
            commandLine.AppendSwitchIfNotNull("/linkresource:", this.LinkResources, new string[] { "LogicalName", "Access" });
            commandLine.AppendWhenTrue("/nologo", this.Bag, "NoLogo");
            commandLine.AppendWhenTrue("/nowin32manifest", this.Bag, "NoWin32Manifest");
            commandLine.AppendPlusOrMinusSwitch("/optimize", this.Bag, "Optimize");
            commandLine.AppendSwitchIfNotNull("/out:", this.OutputAssembly);
            commandLine.AppendSwitchIfNotNull("/ruleset:", this.CodeAnalysisRuleSet);
            commandLine.AppendSwitchIfNotNull("/subsystemversion:", this.SubsystemVersion);
            // If the strings "LogicalName" or "Access" ever change, make sure to search/replace everywhere in vsproject.
            commandLine.AppendSwitchIfNotNull("/resource:", this.Resources, new string[] { "LogicalName", "Access" });
            commandLine.AppendSwitchIfNotNull("/target:", this.TargetType);
            commandLine.AppendPlusOrMinusSwitch("/warnaserror", this.Bag, "TreatWarningsAsErrors");
            commandLine.AppendWhenTrue("/utf8output", this.Bag, "Utf8Output");
            commandLine.AppendSwitchIfNotNull("/win32icon:", this.Win32Icon);
            commandLine.AppendSwitchIfNotNull("/win32manifest:", this.Win32Manifest);

            // Append the analyzers.
            this.AddAnalyzersToCommandLine(commandLine);

            // Append additional files.
            this.AddAdditionalFilesToCommandLine(commandLine);

            // Append the sources.
            commandLine.AppendFileNamesIfNotNull(Sources, " ");
        }
Exemplo n.º 47
0
        protected internal override void AddResponseFileCommands(
            CommandLineBuilderExtension commandLine)
        {
            if (AddModules != null && AddModules.Length > 0)
            {
                commandLine.AppendSwitchIfNotNull("/addmodule:", AddModules, ",");
            }
            if (Bag ["CodePage"] != null)
            {
                commandLine.AppendSwitchIfNotNull("/codepage:", CodePage.ToString());
            }

            commandLine.AppendSwitchIfNotNull("/debug:", DebugType);

            if (Bag ["DelaySign"] != null)
            {
                if (DelaySign)
                {
                    commandLine.AppendSwitch("/delaysign+");
                }
                else
                {
                    commandLine.AppendSwitch("/delaysign-");
                }
            }
            if (Bag ["EmitDebugInformation"] != null)
            {
                if (EmitDebugInformation)
                {
                    commandLine.AppendSwitch("/debug+");
                }
                else
                {
                    commandLine.AppendSwitch("/debug-");
                }
            }
            //fileAlignment
            commandLine.AppendSwitchIfNotNull("/keycontainer:", KeyContainer);
            commandLine.AppendSwitchIfNotNull("/keyfile:", KeyFile);
            // FIXME: add ids from metadata
            if (LinkResources != null)
            {
                foreach (ITaskItem item in LinkResources)
                {
                    commandLine.AppendSwitchIfNotNull("/linkresource:", item.ItemSpec);
                }
            }

            if (NoLogo)
            {
                commandLine.AppendSwitch("/nologo");
            }

            if (Bag ["Optimize"] != null)
            {
                if (Optimize)
                {
                    commandLine.AppendSwitch("/optimize+");
                }
                else
                {
                    commandLine.AppendSwitch("/optimize-");
                }
            }

            if (OutputAssembly != null)
            {
                commandLine.AppendSwitchIfNotNull("/out:", OutputAssembly.ItemSpec);
            }

            if (Resources != null)
            {
                foreach (ITaskItem item in Resources)
                {
                    string logical_name = item.GetMetadata("LogicalName");
                    if (logical_name.Length > 0)
                    {
                        commandLine.AppendSwitchIfNotNull("/resource:",
                                                          String.Format("{0},{1}", item.ItemSpec, logical_name));
                    }
                    else
                    {
                        commandLine.AppendSwitchIfNotNull("/resource:", item.ItemSpec);
                    }
                }
            }

            if (Sources != null)
            {
                foreach (ITaskItem item in Sources)
                {
                    commandLine.AppendFileNameIfNotNull(item.ItemSpec);
                }
            }

            if (TargetType != null)
            {
                commandLine.AppendSwitchIfNotNull("/target:", TargetType);
            }
            if (Bag ["TreatWarningsAsErrors"] != null)
            {
                if (TreatWarningsAsErrors)
                {
                    commandLine.AppendSwitch("/warnaserror+");
                }
                else
                {
                    commandLine.AppendSwitch("/warnaserror-");
                }
            }
            commandLine.AppendSwitchIfNotNull("/win32icon:", Win32Icon);
        }
Exemplo n.º 48
0
            /// <summary>
            /// Generate the command line to be passed to resgen.exe, sans the path to the tool.
            /// </summary>
            private void GenerateResGenCommands(CommandLineBuilderExtension resGenArguments, bool useForResponseFile)
            {
                resGenArguments = resGenArguments ?? new CommandLineBuilderExtension();

                if (ResGen.IsNullOrEmpty(OutputFiles))
                {
                    GenerateOutputFileNames();
                }

                // Append boolean flags if requested
                string useSourcePathSwitch = "/useSourcePath" + (useForResponseFile ? "\n" : String.Empty);
                string publicClassSwitch   = "/publicClass" + (useForResponseFile ? "\n" : String.Empty);

                resGenArguments.AppendWhenTrue(useSourcePathSwitch, Bag, "UseSourcePath");
                resGenArguments.AppendWhenTrue(publicClassSwitch, Bag, "PublicClass");

                // append the references, if any
                if (References != null)
                {
                    foreach (ITaskItem reference in References)
                    {
                        // ResGen.exe response files frown on quotes in filenames, even if there are
                        // spaces in the names of the files.
                        if (useForResponseFile && reference != null)
                        {
                            resGenArguments.AppendTextUnquoted("/r:");
                            resGenArguments.AppendTextUnquoted(reference.ItemSpec);
                            resGenArguments.AppendTextUnquoted("\n");
                        }
                        else
                        {
                            resGenArguments.AppendSwitchIfNotNull("/r:", reference);
                        }
                    }
                }

                if (String.IsNullOrEmpty(StronglyTypedLanguage))
                {
                    // append the compile switch
                    resGenArguments.AppendSwitch("/compile" + (useForResponseFile ? "\n" : String.Empty));

                    // append the resources to compile
                    if (InputFiles != null && InputFiles.Length > 0)
                    {
                        ITaskItem[] inputFiles  = InputFiles;
                        ITaskItem[] outputFiles = OutputFiles;

                        for (int i = 0; i < inputFiles.Length; ++i)
                        {
                            if (useForResponseFile)
                            {
                                // ResGen.exe response files frown on quotes in filenames, even if there are
                                // spaces in the names of the files.
                                if (inputFiles[i] != null && outputFiles[i] != null)
                                {
                                    resGenArguments.AppendTextUnquoted(inputFiles[i].ItemSpec);
                                    resGenArguments.AppendTextUnquoted(",");
                                    resGenArguments.AppendTextUnquoted(outputFiles[i].ItemSpec);
                                    resGenArguments.AppendTextUnquoted("\n");
                                }
                            }
                            else
                            {
                                resGenArguments.AppendFileNamesIfNotNull
                                (
                                    new ITaskItem[] { inputFiles[i], outputFiles[i] },
                                    ","
                                );
                            }
                        }
                    }
                }
                else
                {
                    // append the resource to compile
                    resGenArguments.AppendFileNamesIfNotNull(InputFiles, " ");
                    resGenArguments.AppendFileNamesIfNotNull(OutputFiles, " ");

                    // append the strongly-typed resource details
                    resGenArguments.AppendSwitchIfNotNull
                    (
                        "/str:",
                        new string[] { StronglyTypedLanguage, StronglyTypedNamespace, StronglyTypedClassName, StronglyTypedFileName },
                        ","
                    );
                }
            }