using NuGetFramework.Parse instead of passing Version object
This commit is contained in:
parent
ac3e14c89e
commit
5e574f46d8
2 changed files with 9 additions and 14 deletions
|
@ -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<Type, string> GetProjectAttributes(AssemblyInfoOptions metadata)
|
||||
{
|
||||
var attributes = new Dictionary<Type, string>() {
|
||||
NuGetFramework targetFramework = NuGetFramework.Parse(metadata.TargetFramework);
|
||||
|
||||
var attributes = new Dictionary<Type, string>()
|
||||
{
|
||||
[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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue