From 5e574f46d8324a306fd067da8e9f1b9acf03fd21 Mon Sep 17 00:00:00 2001 From: discostu105 Date: Mon, 22 Feb 2016 09:57:55 +0100 Subject: [PATCH] using NuGetFramework.Parse instead of passing Version object --- .../AssemblyInfoFileGenerator.cs | 9 +++++++-- .../AssemblyInfoOptions.cs | 14 ++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs index e93561d65..ed93e3320 100644 --- a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs +++ b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.CSharp; using System.IO; using System.Runtime.Versioning; using Microsoft.CodeAnalysis.CSharp.Syntax; +using NuGet.Frameworks; namespace Microsoft.DotNet.Cli.Compiler.Common { @@ -59,7 +60,10 @@ namespace Microsoft.DotNet.Cli.Compiler.Common private static Dictionary GetProjectAttributes(AssemblyInfoOptions metadata) { - var attributes = new Dictionary() { + NuGetFramework targetFramework = NuGetFramework.Parse(metadata.TargetFramework); + + var attributes = new Dictionary() + { [typeof(AssemblyTitleAttribute)] = EscapeCharacters(metadata.Title), [typeof(AssemblyDescriptionAttribute)] = EscapeCharacters(metadata.Description), [typeof(AssemblyCopyrightAttribute)] = EscapeCharacters(metadata.Copyright), @@ -71,7 +75,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common }; // only .net 4.0+ compatible - if (metadata.TargetFrameworkVersion == null || metadata.TargetFrameworkVersion >= new Version(4, 0)) { + if (targetFramework.Version >= new Version(4, 0)) + { attributes[typeof(TargetFrameworkAttribute)] = EscapeCharacters(metadata.TargetFramework); }; return attributes; diff --git a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs index 5b66b520f..c59ec0657 100644 --- a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoOptions.cs @@ -49,8 +49,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common public string TargetFramework { get; set; } - public Version TargetFrameworkVersion { get; set; } - public static AssemblyInfoOptions CreateForProject(ProjectContext context) { var project = context.ProjectFile; @@ -74,8 +72,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common Description = project.Description, Title = project.Title, NeutralLanguage = project.Language, - TargetFramework = targetFramework.DotNetFrameworkName, - TargetFrameworkVersion = targetFramework.Version + TargetFramework = targetFramework.DotNetFrameworkName }; } @@ -110,8 +107,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common syntax.DefineOption(TargetFrameworkOptionName, ref targetFramework, UnescapeNewlines, "Assembly target framework"); - syntax.DefineOption(TargetFrameworkVersionOptionName, ref targetFrameworkVersion, UnescapeNewlines, "Assembly target framework version"); - return new AssemblyInfoOptions() { AssemblyFileVersion = fileVersion, @@ -121,8 +116,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common Description = description, InformationalVersion = informationalVersion, Title = title, - TargetFramework = targetFramework, - TargetFrameworkVersion = new Version(targetFrameworkVersion) + TargetFramework = targetFramework }; } @@ -166,10 +160,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common { options.Add(FormatOption(TargetFrameworkOptionName, assemblyInfoOptions.TargetFramework)); } - if (assemblyInfoOptions.TargetFrameworkVersion != null) - { - options.Add(FormatOption(TargetFrameworkVersionOptionName, assemblyInfoOptions.TargetFrameworkVersion.ToString())); - } return options; }