From 7dd4bdf268bcdc7f281b189007fdd83d62b9e7e3 Mon Sep 17 00:00:00 2001 From: Enrico Sada Date: Thu, 11 Feb 2016 15:42:20 +0100 Subject: [PATCH] fix build of target framework net46 --- src/dotnet/commands/dotnet-compile-fsc/Program.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dotnet/commands/dotnet-compile-fsc/Program.cs b/src/dotnet/commands/dotnet-compile-fsc/Program.cs index da332b49b..3dfff1547 100644 --- a/src/dotnet/commands/dotnet-compile-fsc/Program.cs +++ b/src/dotnet/commands/dotnet-compile-fsc/Program.cs @@ -93,8 +93,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions)); allArgs.Add($"{assemblyInfo}"); + bool targetNetCore = commonOptions.Defines.Contains("DNXCORE50"); + //HACK fsc raise error FS0208 if target exe doesnt have extension .exe - bool hackFS0208 = commonOptions.EmitEntryPoint == true; + bool hackFS0208 = targetNetCore && commonOptions.EmitEntryPoint == true; string originalOutputName = outputName; if (outputName != null) @@ -108,7 +110,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc } //set target framework - if (commonOptions.Defines.Contains("DNXCORE50")) + if (targetNetCore) { allArgs.Add("--targetprofile:netcore"); } @@ -126,6 +128,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc .ForwardStdOut() .Execute(); + bool successFsc = result.ExitCode == 0; + if (hackFS0208 && File.Exists(outputName)) { if (File.Exists(originalOutputName)) @@ -135,7 +139,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc //HACK dotnet build require a pdb (crash without), fsc atm cant generate a portable pdb, so an empty pdb is created string pdbPath = Path.ChangeExtension(outputName, ".pdb"); - if (!File.Exists(pdbPath)) + if (successFsc && !File.Exists(pdbPath)) { File.WriteAllBytes(pdbPath, Array.Empty()); }