本文整理汇总了C#中CSharpCompilationOptions.WithPlatform方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpCompilationOptions.WithPlatform方法的具体用法?C# CSharpCompilationOptions.WithPlatform怎么用?C# CSharpCompilationOptions.WithPlatform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSharpCompilationOptions
的用法示例。
在下文中一共展示了CSharpCompilationOptions.WithPlatform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public HostBuildData Create(HostBuildOptions options)
{
var parseOptions = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp6, documentationMode: DocumentationMode.Parse);
var compilationOptions = new CSharpCompilationOptions(
OutputKind.ConsoleApplication,
xmlReferenceResolver: new XmlFileResolver(options.ProjectDirectory),
sourceReferenceResolver: new SourceFileResolver(ImmutableArray<string>.Empty, options.ProjectDirectory),
metadataReferenceResolver: new AssemblyReferenceResolver(
new MetadataFileReferenceResolver(ImmutableArray<string>.Empty, options.ProjectDirectory),
MetadataFileReferenceProvider.Default),
strongNameProvider: new DesktopStrongNameProvider(ImmutableArray.Create(options.ProjectDirectory, options.OutputDirectory)),
assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default);
var warnings = new List<KeyValuePair<string, ReportDiagnostic>>(options.Warnings);
if (options.OutputKind.HasValue)
{
var kind = options.OutputKind.Value;
compilationOptions = compilationOptions.WithOutputKind(kind);
if (compilationOptions.Platform == Platform.AnyCpu32BitPreferred &&
(kind == OutputKind.DynamicallyLinkedLibrary || kind == OutputKind.NetModule || kind == OutputKind.WindowsRuntimeMetadata))
{
compilationOptions = compilationOptions.WithPlatform(Platform.AnyCpu);
}
}
if (!string.IsNullOrEmpty(options.DefineConstants))
{
IEnumerable<Diagnostic> diagnostics;
parseOptions = parseOptions.WithPreprocessorSymbols(CSharpCommandLineParser.ParseConditionalCompilationSymbols(options.DefineConstants, out diagnostics));
}
if (options.DocumentationFile != null)
{
parseOptions = parseOptions.WithDocumentationMode(!string.IsNullOrEmpty(options.DocumentationFile) ? DocumentationMode.Diagnose : DocumentationMode.Parse);
}
if (options.LanguageVersion != null)
{
var languageVersion = CompilationOptionsConversion.GetLanguageVersion(options.LanguageVersion);
if (languageVersion.HasValue)
{
parseOptions = parseOptions.WithLanguageVersion(languageVersion.Value);
}
}
if (!string.IsNullOrEmpty(options.PlatformWith32BitPreference))
{
Platform platform;
if (Enum.TryParse<Platform>(options.PlatformWith32BitPreference, true, out platform))
{
if (platform == Platform.AnyCpu &&
compilationOptions.OutputKind != OutputKind.DynamicallyLinkedLibrary &&
compilationOptions.OutputKind != OutputKind.NetModule &&
compilationOptions.OutputKind != OutputKind.WindowsRuntimeMetadata)
{
platform = Platform.AnyCpu32BitPreferred;
}
compilationOptions = compilationOptions.WithPlatform(platform);
}
}
if (options.AllowUnsafeBlocks.HasValue)
{
compilationOptions = compilationOptions.WithAllowUnsafe(options.AllowUnsafeBlocks.Value);
}
if (options.CheckForOverflowUnderflow.HasValue)
{
compilationOptions = compilationOptions.WithOverflowChecks(options.CheckForOverflowUnderflow.Value);
}
if (options.DelaySign != null)
{
bool delaySignExplicitlySet = options.DelaySign.Item1;
bool delaySign = options.DelaySign.Item2;
compilationOptions = compilationOptions.WithDelaySign(delaySignExplicitlySet ? delaySign : (bool?)null);
}
if (!string.IsNullOrEmpty(options.ApplicationConfiguration))
{
var appConfigPath = FileUtilities.ResolveRelativePath(options.ApplicationConfiguration, options.ProjectDirectory);
try
{
using (var appConfigStream = PortableShim.FileStream.Create(appConfigPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read))
{
compilationOptions = compilationOptions.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.LoadFromXml(appConfigStream));
}
}
catch (Exception)
{
}
}
if (!string.IsNullOrEmpty(options.KeyContainer))
{
compilationOptions = compilationOptions.WithCryptoKeyContainer(options.KeyContainer);
}
if (!string.IsNullOrEmpty(options.KeyFile))
//.........这里部分代码省略.........