Merge pull request #1285 from enricosada/fix_dotnet_compile_fsc
Fix dotnet-compile-fsc
This commit is contained in:
commit
69c5f542e5
1 changed files with 55 additions and 18 deletions
|
@ -12,6 +12,7 @@ using System.Text;
|
||||||
using Microsoft.DotNet.Cli.Compiler.Common;
|
using Microsoft.DotNet.Cli.Compiler.Common;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
{
|
{
|
||||||
|
@ -79,6 +80,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outputName = outputName.Trim('"');
|
||||||
|
tempOutDir = tempOutDir.Trim('"');
|
||||||
|
|
||||||
var translated = TranslateCommonOptions(commonOptions, outputName);
|
var translated = TranslateCommonOptions(commonOptions, outputName);
|
||||||
|
|
||||||
var allArgs = new List<string>(translated);
|
var allArgs = new List<string>(translated);
|
||||||
|
@ -89,8 +93,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions));
|
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions));
|
||||||
allArgs.Add($"{assemblyInfo}");
|
allArgs.Add($"{assemblyInfo}");
|
||||||
|
|
||||||
|
bool targetNetCore = commonOptions.Defines.Contains("DNXCORE50");
|
||||||
|
|
||||||
//HACK fsc raise error FS0208 if target exe doesnt have extension .exe
|
//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;
|
string originalOutputName = outputName;
|
||||||
|
|
||||||
if (outputName != null)
|
if (outputName != null)
|
||||||
|
@ -100,26 +106,18 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
outputName = Path.ChangeExtension(outputName, ".exe");
|
outputName = Path.ChangeExtension(outputName, ".exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
allArgs.Add($"--out:");
|
allArgs.Add($"--out:{outputName}");
|
||||||
allArgs.Add($"{outputName}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var reference in references)
|
//set target framework
|
||||||
|
if (targetNetCore)
|
||||||
{
|
{
|
||||||
allArgs.Add("-r");
|
allArgs.Add("--targetprofile:netcore");
|
||||||
allArgs.Add($"{reference}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var resource in resources)
|
allArgs.AddRange(references.Select(r => $"-r:{r.Trim('"')}"));
|
||||||
{
|
allArgs.AddRange(resources.Select(resource => $"--resource:{resource.Trim('"')}"));
|
||||||
allArgs.Add("--resource");
|
allArgs.AddRange(sources.Select(s => $"{s.Trim('"')}"));
|
||||||
allArgs.Add($"{resource}");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var source in sources)
|
|
||||||
{
|
|
||||||
allArgs.Add($"{source}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
|
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
|
||||||
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
|
||||||
|
@ -130,6 +128,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
.ForwardStdOut()
|
.ForwardStdOut()
|
||||||
.Execute();
|
.Execute();
|
||||||
|
|
||||||
|
bool successFsc = result.ExitCode == 0;
|
||||||
|
|
||||||
if (hackFS0208 && File.Exists(outputName))
|
if (hackFS0208 && File.Exists(outputName))
|
||||||
{
|
{
|
||||||
if (File.Exists(originalOutputName))
|
if (File.Exists(originalOutputName))
|
||||||
|
@ -137,6 +137,13 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
File.Move(outputName, originalOutputName);
|
File.Move(outputName, originalOutputName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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 (successFsc && !File.Exists(pdbPath))
|
||||||
|
{
|
||||||
|
File.WriteAllBytes(pdbPath, Array.Empty<byte>());
|
||||||
|
}
|
||||||
|
|
||||||
return result.ExitCode;
|
return result.ExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +174,29 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
commonArgs.AddRange(options.Defines.Select(def => $"-d:{def}"));
|
commonArgs.AddRange(options.Defines.Select(def => $"-d:{def}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.SuppressWarnings != null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Additional arguments are added verbatim
|
||||||
|
if (options.AdditionalArguments != null)
|
||||||
|
{
|
||||||
|
commonArgs.AddRange(options.AdditionalArguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.LanguageVersion != null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
if (options.Platform != null)
|
if (options.Platform != null)
|
||||||
{
|
{
|
||||||
commonArgs.Add($"--platform:{options.Platform}");
|
commonArgs.Add($"--platform:{options.Platform}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.AllowUnsafe == true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
if (options.WarningsAsErrors == true)
|
if (options.WarningsAsErrors == true)
|
||||||
{
|
{
|
||||||
commonArgs.Add("--warnaserror");
|
commonArgs.Add("--warnaserror");
|
||||||
|
@ -182,7 +207,19 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
commonArgs.Add("--optimize");
|
commonArgs.Add("--optimize");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.GenerateXmlDocumentation == true)
|
if (options.KeyFile != null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.DelaySign == true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.PublicSign == true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.GenerateXmlDocumentation == true)
|
||||||
{
|
{
|
||||||
commonArgs.Add($"--doc:{Path.ChangeExtension(outputName, "xml")}");
|
commonArgs.Add($"--doc:{Path.ChangeExtension(outputName, "xml")}");
|
||||||
}
|
}
|
||||||
|
@ -199,7 +236,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
var win32manifestPath = Path.Combine(AppContext.BaseDirectory, "default.win32manifest");
|
var win32manifestPath = Path.Combine(AppContext.BaseDirectory, "default.win32manifest");
|
||||||
commonArgs.Add($"--win32manifest:\"{win32manifestPath}\"");
|
commonArgs.Add($"--win32manifest:{win32manifestPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue