What do I need to install/configure to run the following makefile on windows 7:
MONO = mono
MONOC = gmcs
MONOCFLAGS = -optimize -reference:${PARSERREF}
GPLEX = ${MONO} gplex.exe
GPPG = ${MONO} gppg.exe
PARSERREF = bin/ShiftReduceParser.dll
CSFILES = Absyn.cs Parser.cs Printer.cs Scanner.cs Test.cs VisitSkeleton.cs AbstractVisitSkeleton.cs
all: test
clean:
rm -f test.pdf test
distclean: clean
rm -f ${CSFILES}
rm -f test.l test.y test.tex
rm -f Makefile
test: Parser.cs Scanner.cs
#echo "Compiling test..."
${MONOC} ${MONOCFLAGS} -out:bin/test.exe ${CSFILES}
Scanner.cs: test.l
${GPLEX} /out:$# test.l
Parser.cs: test.y
${GPPG} /gplex test.y > $#
I have always used Visual Studio, however, this time, this is generated by BNFC (Parser generator). I don't see the csc.exe (CSharp compiler) in this makefile. Can someone please explain this to me?
Note: I have got gplex.exe and gppg.exe and I have .NET installed on my machine.
You need to download and install GNU make for Windows
http://gnuwin32.sourceforge.net/packages/make.htm
Afterwards you open cmd.exe and cd to the directory where the makefile is in.
Then you type make and press enter, or make test in this case.
Related
At the moment I have a visual studio project and I use the docfx.console nuget package to build the documentation, and everything works fine and as expected... on windows. The point is now I want to make a docker image based on mcr.microsoft.com/dotnet/core/sdk:3.1 which is based on a linux image. And compiling in this docker image running the command:
dotnet publish -c Release -o out
Gives the following error
> [build 9/9] RUN dotnet publish -c Release -o out:
#22 1.080 Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
#22 1.080 Copyright (C) Microsoft Corporation. All rights reserved.
#22 1.080
#22 2.852 Restore completed in 215.94 ms for /app/Documentation/Documentation.csproj.
#22 6.299 Documentation -> /app/Documentation/bin/Release/netcoreapp2.1/Documentation.dll
#22 6.402 /bin/sh: 2: /tmp/tmpbd72ebbe5e6b49c1b3244f1f50c8b57a.exec.cmd: /root/.nuget/packages/docfx.console/2.48.1/build/../tools/docfx.exe: Exec format error
#22 6.407 /root/.nuget/packages/docfx.console/2.48.1/build/docfx.console.targets(57,5): error MSB3073: The command ""/root/.nuget/packages/docfx.console/2.48.1/build/../tools/docfx.exe" "/app/Documentation/docfx.json" -o "" -l "log.txt" --logLevel "Verbose"" exited with code 2. [/app/Documentation/Documentation.csproj]
I already did some prodding around and I believe I have the issue mostly solved. Running file on console.exe shows that this is a PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows. And these kind of files should not be executed on linux using sh but with mono. And indeed running:
mono docfx.exe "/app/Documentation/docfx.json" -o "" -l "log.txt" --logLevel "Verbose"
builds the documentation just fine as expected. At this point of course I have a bunch of workarounds to get the documentation building correctly, just remove docfx.console form the csproj and build it manualy from the command line using a docker command.
But the question is, can I also use the nuget package on linux by changing how the docfx.exe command is run by the nuget package? Or is this only possible by actually fixing this in docfx.console?
p.s. in case it matters, the version of docfx.console that I am using is the most recent one available at the time of writing, namely 2.48.1
But the question is, can I also use the nuget package on linux by changing how the docfx.exe command is run by the nuget package? Or is this only possible by actually fixing this in docfx.console?
Create script docfx that runs docfx.exe using Mono, e.g., like this (assuming docfx.exe is located in /opt/docfx/docfx.exe):
echo '#!/bin/bash\nmono /opt/docfx/docfx.exe $#' > /usr/bin/docfx && chmod +x /usr/bin/docfx
Then, pass MSBuild parameter BuildDocToolPath with path to that script, e.g., like this:
dotnet publish -c Release -o out -p:BuildDocToolPath=/usr/bin/docfx
docfx.console will than use this path to execute DocFX. I think the property BuildDocToolPath isn't documented anywhere, but you can see it in source code.
I've been searching for quite some time now, and can't seem to find an answer to this problem. Found only two questions/answers on SO and they still don't answer this question (https://stackoverflow.com/search?q=netcore+publish+mac+app).
I'm working with DotNetCore on Mac, using Visual Studio as the IDE. The app is a Console App, not an ASP.Net app, simple "Hello World" app in C#:
...
Console.Writeline("Hello World");
...
So here's the question... To run the app, I know I can use the "dotnet" command to run it. I'm trying to build/publish the app, as you normally would do in Windows by creating an .exe file, but now on Mac by creating a native binary file.
I have found zero documentation on how to do this, and deploy the application as a self contained app that can run independently without having to call the program using the "dotnet" command. Maybe I'm looking in the wrong places but haven't even found anything on Microsoft's documentation, they all point to documentation for building ASP.Net apps on .NetCore.
Any suggestions?
Found the answer by looking at the "dotnet publish" options:
dotnet publish -c Release --self-contained -r osx.10.13-x64
Where --self-contained includes all required libraries, and -r specifies the runtime target.
$ dotnet publish -c Release --self-contained -a x64
Determining projects to restore...
Restored /Users/walshca/code/temp/MutexThrow/MutexThrow.csproj (in 155 ms).
MutexThrow -> /Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/MutexThrow.dll
MutexThrow -> /Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/publish/
dotnet publish docs
Then I run ./bin/Release/net6.0/osx-x64/publish/MutexThrow
This didn't specify the --output cli arg, so you can see in the build output it defaulted to [project_file_folder]/bin/[configuration]/[framework]/[runtime]/publish/
(In dotnet 6.0 instead of -r runtime target, you can specify --arch x86 and it uses the default RID for your system.)
If your project props sets a different build output, can you find the executable by enumerating files by unix file permissions:
$ gci -r -file | ? UnixMode -match 'x$' | % FullName
/Users/walshca/code/temp/MutexThrow/obj/Release/net6.0/osx-x64/apphost
/Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/MutexThrow
/Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/publish/MutexThrow
Follow up from this question, I'm currently setting up AppVeyor for my project (here) and my .NET Core tests are only shown in the console output but not in the Tests window.
This is the link for the AppVeyor project: ci.appveyor.com/project/Sergio0694/neuralnetwork-net
If some tests fail, the console correctly shows an error and the build is marked as failing, but the Tests window is empty anyways. Same goes for the badge from shields.io which shows 0 total tests, even if I can see many of them being executed from the console output.
Here's the console output:
And here's the Tests window:
Is there something else I have to setup in order for them to be reported correctly outside the console window?
Please add https://www.nuget.org/packages/Appveyor.TestLogger to your test projects.
An arguably cleaner alternative to adding an otherwise unused reference to your test project is to do this in your test script:
cd <test_project_dir>
nuget install Appveyor.TestLogger -Version 2.0.0
cd ..
dotnet test --no-build --no-restore --test-adapter-path:. --logger:Appveyor <test_project_dir>
This has the same effect as adding the reference, in that it makes the testlogger binary available to the test framework, but it doesn't actually change the test project, and therefore doesn't require someone who's not using Appveyor to install the package when they clone and build your repo.
The slight advantage of this solution over outputting and subsequently uploading .trx files (as in the PS script above) is that you should get the test results in real-time, rather than all at the end.
Example appveyor.yml:
version: 0.0.{build}
build_script:
- cmd: dotnet build MySolution.sln
test_script:
- cmd: cd Test
- cmd: nuget install Appveyor.TestLogger -Version 2.0.0
- cmd: cd ..
- cmd: dotnet test --no-build --no-restore --test-adapter-path:. --logger:Appveyor Test
You can add the AppVeyor.TestLogger package to your project, but it can be done without changing your code. You need to output your tests results into an xml file format that AppVeyor understands and then upload it to their HTTP API. The following powershell snippet will iterate through your solution and find each test project, call dotnet test on the csproj and log the output to test-result.trx and then upload the file to AppVeyor.
$config = "release"
# Find each test project and run tests and upload results to AppVeyor
Get-ChildItem .\**\*.csproj -Recurse |
Where-Object { $_.Name -match ".*Test(s)?.csproj$"} |
ForEach-Object {
# Run dotnet test on the project and output the results in mstest format (also works for other frameworks like nunit)
& dotnet test $_.FullName --configuration $config --no-build --no-restore --logger "trx;LogFileName=..\..\test-result.trx"
# if on build server upload results to AppVeyor
if ("${ENV:APPVEYOR_JOB_ID}" -ne "") {
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test-result.trx))
}
# don't leave the test results lying around
Remove-Item .\test-result.trx -ErrorAction SilentlyContinue
}
i have install monodevelop and write a hello world program in C# console but when in run configuration i choose run in external console check box and click on run button monodevelop says: Cannot execute "{Project Path}"
Os: Debian, Kali 2
Edit: and Console.ReadLine() Doesn't work in default run configuration.
screenshot added
screen shot
I had the same problem, here is my solution.
OS: Linux Mint 18.1 Cinnamon 64-Bit
Monodevelop: 6.1.2.44 flatpak installation
afaik MonoDevelop needs xterm or gnome-terminal for running a program in an external console. If both are missing you get "Cannot execute..." errors.
The MonoDevelop log shows:
~/.var/app/com.xamarin.MonoDevelop/cache/MonoDevelop-6.0/Logs/Ide.log
ERROR [2017-01-10 19:47:49Z]: Cannot execute "/home/...exe"
System.InvalidOperationException: Cannot start process because a file name has not been provided.
In my case i had to install xterm and copy it and it's dependencies to the flatpak runtime:
sudo apt-get install xterm
cp -v /usr/bin/xterm ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/bin/
cp -v /usr/lib/x86_64-linux-gnu/libXaw* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /usr/lib/x86_64-linux-gnu/libXmu* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /usr/lib/x86_64-linux-gnu/libutempter* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /lib/x86_64-linux-gnu/libpng12* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
cp -v /lib/x86_64-linux-gnu/libtinfo* ~/.local/share/flatpak/runtime/org.freedesktop.Platform/x86_64/1.4/active/files/lib/
Maybe not the best solution but it works for me.
I found a couple of ways around this:
1.
Instead of creating a console application, create a GTK 2.0 project. For example:
using System;
using Gtk;
namespace Test
{
class MainClass
{
public static void Main(string[] args)
{
/*Application.Init();
MainWindow win = new MainWindow();
win.Show();
Application.Run(); */
Console.WriteLine("Hello World");
}
}
}
And in the Application Output pad, you will see "Hello World".
install mono-runtime (sudo apt-get install mono-runtime)
and go to the bin/Debug/ directory. There you will find an .exe file and you can simply execute it as ./{{NameOfProject}}.exe
I had this problem on on Ubuntu 20.04 (using the latest monodevelop from PPA)
It was because on 20.04,
gnome-terminal-server had moved from /usr/lib/gnome-terminal/ to /usr/libexec/
Monodevelop needs to be updated to take care of this.
My temporary fix:
cd /usr/lib
sudo mkdir gnome-terminal
sudo ln -s /usr/libexec/gnome-terminal-server
Here's an automated two-liner for the "copy xterm" approach (tested on Ubuntu 16.04):
ldd `which xterm` | awk '{if ($2 == \"=>\") print $3}' | grep / | xargs -I{} cp -Lnv {} .local/share/flatpak/runtime/org.freedesktop.Sdk/x86_64/1.4/active/files/lib/
cp -nv `which xterm` .local/share/flatpak/runtime/org.freedesktop.Sdk/x86_64/1.4/active/files/bin/
I had to open a terminal window in Linux Mint Sylvia, and switch to the Project's name, then from there to the bin/Debug folder. I saw that there was an exe created by monoDevelop. I changed the exe's mode to executable. Then I ran the exe by typing its name.exe and it worked.
As per suggestions from this thread on running C# apps sans .NET I've compiled my app using mono. I built the original app using the latest Visual C# .NET Express Edition. It runs fine on .NET on Windows. I then opened up Cygwin and navigated to my source where I compiled the project again, under mono using the following command:
$ mcs <myProjectHere>.cs
This produces MyProject.exe, which can be run from within Cygwin with success, and can be run from the Window command line successfully. Commands used are:
$ mono MyProject.exe
C:\...>mono MyProject.exe
and just for kicks, simply:
C:\...>MyProject.exe
All work as expected. I then tried to build the mono compiled executable into a statically linked binary using the mkbundle command as follows:
$ mkbundle -o MyProject MyProject.exe --deps
This is where things begin to go downhill. It starts off well enough and then complains that the output file (presumably, MyProject.exe) cannot be opened because it is busy. The full output of it all is here:
$ mkbundle -o Program Program.exe --deps
OS is: Windows
Sources: 1 Auto-dependencies: True
embedding: c:\Documents and Settings\bsweeney\My Documents\Visual Studio 2008
\Projects\TestConsole\TestConsole\Program.exe
embedding: C:\PROGRA~1\Mono-2.2\lib\mono\2.0\mscorlib.dll
Compiling:
as -o temp.o temp.s
gcc -mno-cygwin -g -o Program -Wall temp.c `pkg-config --cflags --libs mono|dos2
unix` temp.o
/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/bin/ld: cannot op
en output file Program.exe: Device or resource busy
collect2: ld returned 1 exit status
[Fail]
I claim that my unix gcc toolchain is installed and in good condition because I've been able to successfully compile a few c++ apps in eclipse using it recently (although i supposed i should be open to any number of problems...).
Anyone ever run into anything like this? I'm stumped...
It seems like it's trying to output into MyProject.exe, which is the same as the input file.
Try running
$ mkbundle -o ProgramOutput Program.exe --deps
This is just a guess, by the way, since I don't know mkbundle.