Getting Exception in the Output
zaripych opened this issue · comments
After successful build I get this thing below and a unexpected app termination popup:
Unhandled Exception: System.ArgumentException: The path is not of a legal form.
Parameter name: path
at System.IO.Path.GetDirectoryName(String path)
at DotnetMono.Main.main(String[] argv)
Might be related to the MSBUILD_EXE_PATH
environment variable being empty on my machine.
Package version: 0.3.4
mono --version
:
Mono JIT compiler version 5.4.1.7 (2017-06/e66d9abbb27 Wed Oct 25 12:10:41 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: yes(3.6.0svn-mono-master/8b1520c8aae)
GC: sgen (concurrent by default)
dotnet --version
2.1.4
Hmm, interesting. The question now is how to properly get MSBUILD_EXE_PATH
? https://github.com/dotnet/cli/blob/master/src/dotnet/commands/dotnet-run/RunCommand.cs#L187 is able to obtain it because they are running in the directory they know about.
I thought MSBUILD_EXE_PATH
was set when dotnet tools are running. Did they change this in dotnet 2.1.4? I'm gonna have to dig deep into this one.
Also what OS are you running?
Could you also turn on Verbose Logging with the --loggerlevel verbose
flags?
When build is successfull:
output.txt
When build is not successfull:
failed-output.txt
Both of these generate following output:
dotnet mono --framework net461 --loggerlevel verbose > output.txt
Unhandled Exception: System.ArgumentException: The path is not of a legal form.
Parameter name: path
at System.IO.Path.GetDirectoryName(String path)
at DotnetMono.Main.main(String[] argv)
and
dotnet mono --framework net461 --loggerlevel verbose > failed-output.txt
Unhandled Exception: System.Exception: dotnet failed with exit code 1
at DotnetMono.Shell.executeOrFail@190-1.Invoke(String message)
at DotnetMono.Shell.executeOrFail(String program, FSharpList`1 argsList, String workingdir, IEnumerable`1 envVars)
at DotnetMono.Shell.dotnetBuild@198.Invoke(IEnumerable`1 envVars)
at DotnetMono.Main.main(String[] argv)
My OS is MacOS 10.13.3.
Running this command: dotnet /usr/local/share/dotnet/sdk/2.1.4/MSBuild.dll
seem to trigger the execution of MSBuild. So you can base your search on which dotnet
which gives usr/loca/share/dotnet/dotnet
. I'm not sure if this is this MSBuild that you need - or the one from mono
, which is here: /Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild
.
Ok doesn't look like it's an issue with MSBUILD_EXE_PATH
since it's getting passed that point in the logs.
It looks like your project isn't outputting an exe:
[16:43:57 DBG] Run Location : <dotnet-mono>
Seems to also be the case with these logs
Restore completed in 8.58 ms for /Users/${user}/Projects/${project}/query/query.csproj.
Restore completed in 8.56 ms for /Users/${user}/Projects/${project}/browser-tests/browser-tests.csproj.
Restore completed in 21.39 ms for /Users/${user}/Projects/${project}/browser-tests/browser-tests.csproj.
query -> /Users/${user}/Projects/${project}/query/bin/Debug/netstandard2.0/WebDriver.Query.dll
browser-tests -> /Users/${user}/Projects/${project}/browser-tests/bin/Debug/net461/WebDriver.Query.BrowserTests.dll
Somehow your browser-tests
are outputting a dll instead of an exe and that's why it can't find anything to run.
@TheAngryByrd My assumption about MSBUILD_EXE_PATH
was based on the stack trace:
Unhandled Exception: System.ArgumentException: The path is not of a legal form.
Parameter name: path
at System.IO.Path.GetDirectoryName(String path)
at DotnetMono.Main.main(String[] argv)
I don't know F#, but saw globalProperties
variable initialized and that seemed the only place GetDirectoryName
was used. I'm sorry if I misled you.
When I try to build my project for net461
using dotnet build
it fails unable to find the targeting pack. So when found a link to this tool in a thread about the dotnet
not being able to pickup mono
paths I just jumped to it without reading the docs first. The tool seemed to work, when I run dotnet mono
it actually also builds the project successfully (as a side effect!), but would output the error I mentioned - so I misinterpreted its usage.
So it seems I misunderstood its behaviour to find exe
file in current directory and execute it. I think the error message should be better in this case e.g. Cannot find an executable to run in current directory
. I think it would be great if I could use the tool to dotnet mono build/run/test
. Or maybe you can suggest a better way to do this?
Thank you for your efforts in developing this tool and for your help.
I should definitely make a better error message around not finding a runnable exe. I'll make a PR for that soon.
Just to give history and context:
I made this tool because dotnet run
doesn't run executables created by mono. So this is trying to mock the same behavior until the dotnet core supports mono (if ever).
To do just dotnet build
with mono you can set export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5/
in your build.sh
or in your .bashrc
or .bash_profile
which will allow for building net45+ with mono and the dotnet core tooling. Someone did suggest a "build only" flag here: #22
As for dotnet test
this is also in a poor state for mono (see https://github.com/dotnet/cli/issues/3073). If you're using xunit, I added mono support to dotnet-xunit and you can use that to run the tests instead. Other than xunit I don't know of anyone supporting mono.
As such I should also include this stuff in the readme.
I just updated the README with this info https://github.com/TheAngryByrd/dotnet-mono#faq. I'll get around to some better error messages later tonight.