From e08401aed6a973b6b908c0c5a7bedc6c5de79eba Mon Sep 17 00:00:00 2001 From: discostu105 Date: Mon, 22 Feb 2016 10:53:01 +0100 Subject: [PATCH] handle case where TargetFramework is null --- .../AssemblyInfoFileGenerator.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs index ed93e3320..fce3d6db1 100644 --- a/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs +++ b/src/Microsoft.DotNet.Compiler.Common/AssemblyInfoFileGenerator.cs @@ -60,8 +60,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common private static Dictionary GetProjectAttributes(AssemblyInfoOptions metadata) { - NuGetFramework targetFramework = NuGetFramework.Parse(metadata.TargetFramework); - var attributes = new Dictionary() { [typeof(AssemblyTitleAttribute)] = EscapeCharacters(metadata.Title), @@ -74,10 +72,10 @@ namespace Microsoft.DotNet.Cli.Compiler.Common [typeof(NeutralResourcesLanguageAttribute)] = EscapeCharacters(metadata.NeutralLanguage) }; - // only .net 4.0+ compatible - if (targetFramework.Version >= new Version(4, 0)) + NuGetFramework targetFramework = string.IsNullOrEmpty(metadata.TargetFramework) ? null : NuGetFramework.Parse(metadata.TargetFramework); + if (targetFramework != null && !(targetFramework.IsDesktop() && targetFramework.Version < new Version(4, 0))) { - attributes[typeof(TargetFrameworkAttribute)] = EscapeCharacters(metadata.TargetFramework); + attributes[typeof(TargetFrameworkAttribute)] = EscapeCharacters(metadata.TargetFramework); // TargetFrameworkAttribute only exists since .NET 4.0 }; return attributes; }