doing dotnet fable webpack with malformed fsproj or an fsproj with some errors (not compile error, sdk/proj errors), generate a not awesome error message (so not in standard with fable awesomeness)
NOTE the message contains the msbuild path and args, so user can rerun these to see the real error. but should be not needed,
dotnet fable webpackmsbuild command, but not the msbuild error messageC:\Users\Phillip Carter\AppData\Local\dotnetcore\dotnet.exe fable webpack -- -p
Fable (1.3.2) daemon started on port 61225
CWD: C:\repos\SAFE-BookStore\src\Client
cmd /C node "C:\repos\SAFE-BookStore\node_modules\webpack\bin\webpack.js" -p
Bundling for production...
ERROR: MSBuild failed with exitCode -2147450735 Working Directory: 'C:\repos\SAFE-BookStore\src\Client' Exe Path: 'dotnet' Args: 'msbuild C:\repos\SAFE-BookStore\src\Client\Client.fsproj /p:SkipCompilerExecution=true /p:ProvideCommandLineArgs=true /p:CopyBuildOutputToOutputDirectory=false /p:UseCommonOutputDirectory=true /t:_Inspect_FscArgs "/p:_Inspect_FscArgs_OutFile=C:\Users\Phillip Carter\AppData\Local\Temp\tmpA729.tmp.FscArgs.txt" /p:DesignTimeBuild=true /t:_Inspect_GetResolvedProjectReferences "/p:_Inspect_GetResolvedProjectReferences_OutFile=C:\Users\Phillip Carter\AppData\Local\Temp\tmpA72A.tmp.GetResolvedProjectReferences.txt" /t:_Inspect_GetProperties "/p:_Inspect_GetProperties_OutFile=C:\Users\Phillip Carter\AppData\Local\Temp\tmpA72B.tmp.GetProperties.txt" /nologo /verbosity:quiet'
at Fable.CLI.ProjectCoreCracker.projInfo(FSharpList`1 additionalMSBuildProps, String file)
at Fable.CLI.ProjectCracker.fullyCrackFsproj(String projFile)
at Fable.CLI.ProjectCracker.getProjectOptionsFromFsproj(Message msg, String projFile)
at Fable.CLI.ProjectCracker.retry@275(FSharpChecker checker, Message msg, String projFile, DateTime retryUntil, Unit unitVar0)
at Fable.CLI.ProjectCracker.retryGetProjectOpts(FSharpChecker checker, Message msg, String projFile)
at Fable.CLI.ProjectCracker.getFullProjectOpts(FSharpChecker checker, Message msg, String projFile)
at Fable.CLI.StateUtil.createProject(FSharpChecker checker, String[] dirtyFiles, FSharpOption`1 prevProject, Message msg, String projFile)
at Fable.CLI.StateUtil.updateState(FSharpChecker checker, FSharpMap`2 state, Message msg)
at [email protected](Tuple`2 _arg1)
As a note, if you try to rerun that command dotnet msbuild and args, you'll see the real error who can help you, for example
The specified SDK version [2.0.3] from global.json [C:\Users\ddltd2\Downloads\SAFE-BookStore-master\global.json] not found; install specified SDK version Did you mean to run dotnet SDK commands? Please install dotnet SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
ref https://github.com/enricosada/dotnet-proj-info/issues/14 ( /cc @Xiu-Li @cartermp )
dotnet-fable use Dotnet.ProjInfo library to parse the fsprojDotnet.ProjInfo invoke dotnet msbuilddotnet fable in https://github.com/fable-compiler/Fable/blob/720bda6853ecb0f21a7273c4a06ed8482e5aee5b/src/dotnet/dotnet-fable/ProjectCoreCracker.fs#L29-L41 read the msbuild output/err stream ( sbErr, sbOut ), but doesnt use that when returning the error message in https://github.com/fable-compiler/Fable/blob/720bda6853ecb0f21a7273c4a06ed8482e5aee5b/src/dotnet/dotnet-fable/ProjectCoreCracker.fs#L102-L108.
Fable version (dotnet fable --version): any
writing this issue there so if you see that error, you know how to read the real error.
I'll send a PR
@alfonsogarciacaro some of the issue ppl see now with some template, are related to this, because it install 2.1.2 (with fake) but try to use 2.0.3 (by global.json).
I'll speedup the PR, didnt see 2.1 coming to fast
A workaround (to debug the actual issue) is the following in the fake script:
let runDotNetRedirect cmd workingDir =
let result =
DotNet.exec (withWorkDir workingDir >> DotNet.Options.withRedirectOutput true) cmd ""
let output =
result.Results
|> Seq.map (fun c ->
sprintf "%s%s" (if c.IsError then "std_err:" else "std_out:") c.Message)
|> fun l -> System.String.Join("\n", l)
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s. \n%s" cmd workingDir output
// ..
try
runDotNetRedirect "fable webpack" "dir/proj"
with e when e.Message.Contains "MSBuild failed with exitCode" ->
// Workaround for https://github.com/fable-compiler/Fable/issues/1285
// try to improve error message
printfn "trying to improve msbuild error..."
let lines =
e.Message.Split([|'\n'|])
|> Seq.filter (fun l -> l.Contains "MSBuild failed with exitCode")
for line in lines do
let wdStartStr = "Working Directory: '"
let wdStartIdx = line.IndexOf(wdStartStr)
let middleStr = "' Exe Path: 'dotnet' Args: '"
let middleIdx = line.IndexOf(middleStr)
if wdStartIdx < 0 || middleIdx < 0 then
raise <| exn(sprintf "Could not find \"%s\" or \"%s\" in \"%s\"" wdStartStr middleStr line, e)
let realWdStartIdx = wdStartIdx + wdStartStr.Length
let wd = line.Substring(realWdStartIdx, middleIdx - realWdStartIdx)
let realArgLineIdx = middleIdx + middleStr.Length
let argLine = line.Substring(realArgLineIdx, line.Length - realArgLineIdx - 1)
let verboseLine = argLine.Replace("/verbosity:quiet", "/verbosity:detailed")
// Run with Process.StartInfo.FileName = dotnet as that is what dotnet-proj/fable is doing internally)
runProcess "dotnet" verboseLine wd |> ignore
reraise()
Hi @enricosada! What's the status of this? Is this actionable in this repo or should we move the issue to Dotnet.ProjInfo?
Closing for now, please reopen if necessary.
Most helpful comment
writing this issue there so if you see that error, you know how to read the real error.
I'll send a PR