Plumbde through the option
This commit is contained in:
parent
e56858b4b3
commit
2deb9d343a
8 changed files with 41 additions and 5 deletions
|
@ -32,6 +32,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
|
||||
internal static readonly OptionTemplate s_publicSignTemplate = new OptionTemplate("public-sign");
|
||||
|
||||
internal static readonly OptionTemplate s_debugTypeTemplate = new OptionTemplate("debug-type");
|
||||
|
||||
internal static readonly OptionTemplate s_emitEntryPointTemplate = new OptionTemplate("emit-entry-point");
|
||||
|
||||
internal static readonly OptionTemplate s_generateXmlDocumentation = new OptionTemplate("generate-xml-documentation");
|
||||
|
@ -44,6 +46,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
IReadOnlyList<string> suppressWarnings = null;
|
||||
string languageVersion = null;
|
||||
string platform = null;
|
||||
string debugType = null;
|
||||
bool? allowUnsafe = null;
|
||||
bool? warningsAsErrors = null;
|
||||
bool? optimize = null;
|
||||
|
@ -62,6 +65,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
|
||||
syntax.DefineOptionList(s_additionalArgumentsTemplate.LongName, ref additionalArguments, "Pass the additional argument directly to the compiler");
|
||||
|
||||
syntax.DefineOption(s_debugTypeTemplate, ref debugType, "The type of PDB to emit: portable or full");
|
||||
|
||||
syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion,
|
||||
"The version of the language used to compile");
|
||||
|
||||
|
@ -104,6 +109,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
KeyFile = keyFile,
|
||||
DelaySign = delaySign,
|
||||
PublicSign = publicSign,
|
||||
DebugType = debugType,
|
||||
EmitEntryPoint = emitEntryPoint,
|
||||
GenerateXmlDocumentation = generateXmlDocumentation,
|
||||
AdditionalArguments = additionalArguments
|
||||
|
@ -115,6 +121,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
var defines = options.Defines;
|
||||
var suppressWarnings = options.SuppressWarnings;
|
||||
var languageVersion = options.LanguageVersion;
|
||||
var debugType = options.DebugType;
|
||||
var platform = options.Platform;
|
||||
var allowUnsafe = options.AllowUnsafe;
|
||||
var warningsAsErrors = options.WarningsAsErrors;
|
||||
|
@ -183,6 +190,11 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
args.Add(s_publicSignTemplate.ToLongArg(publicSign));
|
||||
}
|
||||
|
||||
if (debugType != null)
|
||||
{
|
||||
args.Add(s_debugTypeTemplate.ToLongArg(debugType));
|
||||
}
|
||||
|
||||
if (emitEntryPoint != null)
|
||||
{
|
||||
args.Add(s_emitEntryPointTemplate.ToLongArg(emitEntryPoint));
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Runtime.InteropServices;
|
|||
using System.Text;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.Emit;
|
||||
using Microsoft.CodeAnalysis.Host.Mef;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.DotNet.Cli.Compiler.Common;
|
||||
|
@ -195,9 +196,14 @@ namespace Microsoft.DotNet.ProjectModel.Workspaces
|
|||
platform = Platform.AnyCpu;
|
||||
}
|
||||
|
||||
var debugType = StringComparer.OrdinalIgnoreCase.Equals(compilerOptions.DebugType, "full")
|
||||
? DebugInformationFormat.pdb
|
||||
:DebugInformationFormat.Portable;
|
||||
|
||||
options = options
|
||||
.WithAllowUnsafe(allowUnsafe)
|
||||
.WithPlatform(platform)
|
||||
.WithDebugInformationFormat(debugType)
|
||||
.WithGeneralDiagnosticOption(warningsAsErrors ? ReportDiagnostic.Error : ReportDiagnostic.Default)
|
||||
.WithOptimizationLevel(optimize ? OptimizationLevel.Release : OptimizationLevel.Debug);
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
|
||||
public bool? PublicSign { get; set; }
|
||||
|
||||
public string DebugType { get; set; }
|
||||
|
||||
public bool? EmitEntryPoint { get; set; }
|
||||
|
||||
public bool? PreserveCompilationContext { get; set; }
|
||||
|
@ -49,6 +51,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
KeyFile == other.KeyFile &&
|
||||
DelaySign == other.DelaySign &&
|
||||
PublicSign == other.PublicSign &&
|
||||
DebugType == other.DebugType &&
|
||||
EmitEntryPoint == other.EmitEntryPoint &&
|
||||
GenerateXmlDocumentation == other.GenerateXmlDocumentation &&
|
||||
PreserveCompilationContext == other.PreserveCompilationContext &&
|
||||
|
@ -131,6 +134,11 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
result.PublicSign = option.PublicSign;
|
||||
}
|
||||
|
||||
if (option.DebugType != null)
|
||||
{
|
||||
result.DebugType = option.DebugType;
|
||||
}
|
||||
|
||||
if (option.EmitEntryPoint != null)
|
||||
{
|
||||
result.EmitEntryPoint = option.EmitEntryPoint;
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
compilerOptions.KeyFile,
|
||||
compilerOptions.DelaySign,
|
||||
compilerOptions.PublicSign,
|
||||
compilerOptions.DebugType,
|
||||
compilerOptions.EmitEntryPoint,
|
||||
compilerOptions.GenerateXmlDocumentation);
|
||||
}
|
||||
|
|
|
@ -569,6 +569,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
KeyFile = rawOptions.ValueAsString("keyFile"),
|
||||
DelaySign = rawOptions.ValueAsNullableBoolean("delaySign"),
|
||||
PublicSign = rawOptions.ValueAsNullableBoolean("publicSign"),
|
||||
DebugType = rawOptions.ValueAsString("debugType"),
|
||||
EmitEntryPoint = rawOptions.ValueAsNullableBoolean("emitEntryPoint"),
|
||||
GenerateXmlDocumentation = rawOptions.ValueAsNullableBoolean("xmlDoc"),
|
||||
PreserveCompilationContext = rawOptions.ValueAsNullableBoolean("preserveCompilationContext")
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
compilationOptionsObject[DependencyContextStrings.KeyFilePropertyName]?.Value<string>(),
|
||||
compilationOptionsObject[DependencyContextStrings.DelaySignPropertyName]?.Value<bool>(),
|
||||
compilationOptionsObject[DependencyContextStrings.PublicSignPropertyName]?.Value<bool>(),
|
||||
compilationOptionsObject[DependencyContextStrings.DebugTypePropertyName]?.Value<string>(),
|
||||
compilationOptionsObject[DependencyContextStrings.EmitEntryPointPropertyName]?.Value<bool>(),
|
||||
compilationOptionsObject[DependencyContextStrings.GenerateXmlDocumentationPropertyName]?.Value<bool>()
|
||||
);
|
||||
|
@ -149,4 +150,4 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
public bool Serviceable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,10 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
{
|
||||
o[DependencyContextStrings.PublicSignPropertyName] = compilationOptions.PublicSign;
|
||||
}
|
||||
if (compilationOptions.DebugType != null)
|
||||
{
|
||||
o[DependencyContextStrings.DebugTypePropertyName] = compilationOptions.DebugType;
|
||||
}
|
||||
if (compilationOptions.EmitEntryPoint != null)
|
||||
{
|
||||
o[DependencyContextStrings.EmitEntryPointPropertyName] = compilationOptions.EmitEntryPoint;
|
||||
|
@ -157,4 +161,4 @@ namespace Microsoft.Extensions.DependencyModel
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
|
||||
// Generate assembly info
|
||||
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs");
|
||||
|
||||
|
||||
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateCSharp(assemblyInfoOptions, sources));
|
||||
|
||||
allArgs.Add($"\"{assemblyInfo}\"");
|
||||
|
@ -106,7 +106,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
// Only the first should be quoted. This is handled
|
||||
// in dotnet-compile where the information is present.
|
||||
allArgs.AddRange(resources.Select(resource => $"-resource:{resource}"));
|
||||
|
||||
|
||||
allArgs.AddRange(sources.Select(s => $"\"{s}\""));
|
||||
|
||||
var rsp = Path.Combine(tempOutDir, "dotnet-compile-csc.rsp");
|
||||
|
@ -129,7 +129,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
{
|
||||
"-nostdlib",
|
||||
"-nologo",
|
||||
"-debug:portable"
|
||||
};
|
||||
|
||||
return args;
|
||||
|
@ -214,6 +213,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
|||
commonArgs.Add("-t:library");
|
||||
}
|
||||
|
||||
commonArgs.Add((string.IsNullOrEmpty(options.DebugType) || options.DebugType == "portable")
|
||||
? "-debug:portable"
|
||||
: "-debug:full");
|
||||
|
||||
return commonArgs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue