How to handle an .fsproj file on the command line? - command-line

I would like to use exercism to solve F# exercises. I do this on Fedora.
Exercism downloads an .fsproj file. How can I handle it from the command line?
Is there something like the command make for a Makefile?

If you have the dotnet SDK installed.
dotnet build X.fsproj should restore and build the project.
dotnet run X.fsproj will run it. You can also run it against a .sln file.
dotnet test X.fsproj will execute your unit tests. Note: Here it reported I only had 1 test file (wrong) but picked up all my tests.
To test if you have it installed and on your PATH, execute: dotnet --version. The current version is 3.1.
dotnet --help will show you all possible commands.
Of interest may be that F# Interactive is now baked into the SDK.
dotnet fsi to enter interactive environment.
#quit;; to exit interactive environment.
This allows you to play with F# right in the command line.

Related

dotnet-ef does not exist - Windows 10 WSL (Ubuntu)

I've been testing dotnet core 3 in different OS like Windows and Linux(Ubuntu). All of them are working fine with EF Core!
However, I decided to give a chance to Windows WSL - Windows Subsystem for Linux and see how it works. That's why I'm here!
The problem with WSL and Ubuntu 18.04 is:
I installed EF Core globally and restarted the terminal. * Up to this point, the EF version is 3.1.4
> dotnet tool install --global dotnet-ef
I get the following error when I try to run any dotnet ef command:
> dotnet ef database update
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Has anyone faced the same error using Windows WSL and Ubuntu 18.04?
Finally I found the solution!
I've tried to export the PATH variable export PATH="$PATH:$HOME/.dotnet/tools" as #kapsiR mentioned. However, it was valid for a single terminal session only. So if I close the terminal and open again, the $PATH configuration disappears.
The solution that works for me:
cd /home/yourUserName
Edit the file .zshrc and add this line export PATH="$PATH:$HOME/.dotnet/tools/". NOTE: I'm using zsh shell in this case. You should change it if you are using a different one.
Restart your terminal
Sadly, the PATH isn't exported directly after the installation of the dotnet-sdk.
You basically have two options:
Add the tool path manually for the current session:
export PATH="$PATH:$HOME/.dotnet/tools"
OR
Start a new session of the WSL
With the dotnet-sdk there comes a script which adds it to the PATH, it's located under /etc/profile.d/dotnet-cli-tools-bin-path.sh.

Launch .NET Core project in VS Code using dotnet run

We have a .net core 2.0 project that we've been using in Visual Studio. I want to switch to using VS Code. I updated the launchsettings.json to include a Project launch profile (instead of IIS) and made the necessary changes to be able to use the dotnet cli to run it.
However, when I try to launch it in VS Code I don't see where the dotnet run is being used because I want to use that command to run the project since we need to pass a configuration to that command in order for it to work. The command line looks like this:
dotnet run -c Dev --launch-profile Project
I don't know how to set up vs code to launch using the above command.

Run C# Console Application on Visual Studio Code Editor on Windows

Is there any way to create (from scratch) and run simple C# Console app in VSCode editor. ?
Can you please provide step-by-step instruction how I can do that?
What kind of files I must to include (except HelloWolrd.cs obviously)?
What kind of commands I must to execute?
Navigate to the folder you want to create the console app in. In VSCode, use Ctrl+` to open the terminal window or go to View and select Integrated Terminal. Now type the following below:
dotnet new console
dotnet restore
dotnet run
The best way at this present time to create a console application is to create a DNX style Console Application.
I would advise that you download and install the generator-aspnet Yeoman generator and use that to generate a DNX Console application. Once you've got generator-aspnet installed, in your terminal/console app type yo aspnet and select Console Application.
Here's a thorough guide to creating a DNX Console application which will work with VS Code: http://docs.asp.net/en/latest/dnx/console.html
I was trying to get a 'hello world' set up using visual studio code and c# on mac/osx.
the way I did it was as follows:
Install VS Code and the C# extension
Here (https://www.microsoft.com/net/core#macos) are instructions for installing dotnet core using brew:
Install OpenSSL
brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
Install dotnet core pkg: https://go.microsoft.com/fwlink/?LinkID=827526
Create a folder somewhere and in that folder run dotnet new
Go into VS code and open the folder to get the project loaded
Open the terminal in that folder and run dotnet run
To create run as a task
CMD+shift+P then type task
select the Task: Configure Task Runner option
in the tasks.json file after the build task, add the following:
{
"taskName":"run",
"args": [
"${workspaceRoot}/project.json"
]
}

Chmod u+x windows cmd

I'm trying to install Scalatra on windows seven and need to change a file to executable...the Scalatra documentation says to do this, which is unix. What is the windows equivalant?
chmod u+x srt
You can simply open the relevant folder with a unix command prompt (I use git bash) and execute the unix commands from there
To get scalatra-sbt going on Windows, either port you own sbt.bat from scalatra-sbt, or install chmod via cygwin.
Assuming you've successfully installed the rest of Conscript and giter8, you can start a project that downloads scalatra-sbt. From there, one can look through the ./sbt source, and port the bash script functionality to your own windows specific script, or install a unix compatibility layer into Windows. If you go down the "windows specific script" route, perhaps the scalatra-sbt would appreciate the project contribution.
The "unix compatibility layer" route will eventually allow you to run ./sbt. chmod is a unix command line function, and is provided in a default package of the tool set cygwin, which provides a complete lunix-like environment. Once inside a cygwin terminal, you can chmod your file, as mentioned in the scalatra-sbt first project.
Diving into the contents of ./sbt from scalatra-sbt, this is actually unix script wrapper around the scala build tool (also referred to, confusingly, as sbt). If while trying to run ./sbt you get strange '\r' errors, install the cygwin package dos2unix, and then run it on the sbt file. If you run into any "which: no curl in..." or "which: no wget in..." errors, go back to the cygwin installer, find those packages such as wget, and then install those programs.
By the way, the last thing the scalatra-sbt script runs is the Scala build tool. The Scala build tool sbt itself has many reported issues with cygwin's default configuration, so you will likely need to do more research. Depending on what issues you're running into on your specific setup, you may need to make changes to the end of the ./sbt script to adjust the parameters used to launch the Scala build tool.

Building swagger-codegen on Windows - is it ok to use Git Bash?

I am attempting to build swagger-codegen on Windows 7 x64. I ran into a problem when I had to run ./sbt assembly. I couldn't see how to do it from the Windows command prompt.
Instead, I ran it from Git-Bash. It ran successfully, with warnings, but no errors.
Is this an acceptable solution?
I ask because I am stuck on the next step running the template client for petstore.
./bin/scala-petstore.sh produces the following error:
Error: Could not find or load main class Files
I believe the OP was successful in running sbt on Windows 7. However, I believe the OP issue comes from running the scala-petstore.sh script.
I have found the swagger generation scripts depend on a bash shell. However, on Windows Git Bash shell, the basic scala executable does not works. Run "scala -version" on Windows from a CMD shell and you get the scala version. Run "scala -version" on Windows from a GitBash shell and you get:
$ scala -version
Error: Could not find or load main class Files
Answered in another question/topic: Does anyone know how to run the scala executable in Git Bash shell?
The official SBT distribution at scala-sbt.org includes an sbt.bat-file that works on windows.