本文整理汇总了C#中Microsoft.Build.Tasks.CommandLineBuilderExtension.AppendNestedSwitch方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineBuilderExtension.AppendNestedSwitch方法的具体用法?C# CommandLineBuilderExtension.AppendNestedSwitch怎么用?C# CommandLineBuilderExtension.AppendNestedSwitch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Tasks.CommandLineBuilderExtension
的用法示例。
在下文中一共展示了CommandLineBuilderExtension.AppendNestedSwitch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCommandLineCommands
/// <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();
}
示例2: GenerateCommandLineCommands
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();
}