Run F# script in Visual Studio - visual-studio

I've been looking into running some F# scripts to automate some things. But I can't seem to be able to find a way to run the scripts. I've to an F# file.
Test.fsx
let helloWolrd = "Hello World"
printfn $"{helloWolrd}"
I know I can run it by selecting and running it with Alt+Enter but this just seems unpractical. How can I run an entire F# file in Visual Studio? Not by selecting the part I want to run.

As you noted you can send individual snippets of F# files to F# Interactive by highlighting the lines you wish to send using Alt + Enter keyboard combination in Visual Studio. The same works with VS Code.
You can run entire scripts using dotnet fsi script.fsx from the command line. This works from Developer PowerShell within VS or other CLIs.

Related

How to write and debug a PowerShell module using VIsual Studio Powershell Tools?

I'd like to take advantage of Visual Studio's debugging capabilities when writing PowerShell scripts, especially PowerShell modules. Thus, I have installed the PowerShell tools for Visual Studio. I created a new PowerShell module project - but I can't figure out how to properly run and debug?
When running such a project I'd expect that the module is loaded and all functions are available in the debug window - and that any code execution would stop at break points.
However, I can't manage to run a module that way. In Solution Properties => Advanced => Entry point I can only select ps1 files. I've RTFM at https://docs.poshtools.com/ but didn't find anything about modules. Just to avoid any confusion, I am not developing anything with C# or VB in this project, just pure PS. I have been developing PS before using Visual Studio Code, but as I am more comfortable with Visual Studio 2019 I might be able to use it for PS development as well.
Any suggestions?

Restart Shell Visual Studio

Due to company standards I switched from VS Code to it's bigger brother VS Pro.
When using VS Code while coding with Powershell I do have the possibility to restart powershell (within Code). Easy thing, you close the console and Code asks you whether you want to start a new powershell session.
I need to do so to get my latest changes (within my code) to be activated/effective. How does one do that in Visual Studio (no code)?

How do I save test results from Test Explorer in Visual Studio 2017?

I have an issue with Visual Studio 2017. I generally run a set of tests locally on my own computer using Test Explorer and using Microsoft's own Unit Testing tools in the Visual Studio library. This can take quite sometime. Problem is, if I close visual studio at any point, the results of these tests are lost forever: the pass, the fail, the output, everything.
I need a way to save the results of my tests in case this happens. I'd love it if VS didn't just wipe my test results like this.
I have to run many tests in different windows, using the command prompt to do this is incredibly laborious.
You can use the command line tool VSTest.Console.exe command-line options and save the output to file using /Logger: option.
It can be found under
(Visual-Studio-Directory)\(Version-Year)\Common7\IDE\Extensions\TestPlatform
Sample:
vstest.console.exe "C:\TestProjectFolder\TestProject.dll" --logger:trx
You can configure trace logging using a test settings file, documented here.

Visual Studio Code [Ubuntu 16.04] - Running the code

I have a few issues with Visual Studio and I would like for it to function slightly more like Geany.
I am running Ubuntu 16.04 and when running cpp in Geany it opens a terminal for me when running the code. This allows for me to interact with the program that was written (ie. input values etc.).
Visual Studio utilizes json, which I admit that I am still trying to figure out for the most part. I have downloaded a few extensions (ie. codeRunner). This runs the code in the output box but does not allow for me to input any values etc. Most of the coding that is being done is for class, all of which is in C++.
Questions:
How can I get Visual Studio Code to open a terminal to run the code? I'd be fine with the output box at the bottom, I just can not figure out how to get it to allow me to input or interact with the program.
Secondly, Visual Studio will NOT run any files that have in the title. Instructor sends a ton of files that I have to trouble shoot to get to run and they include spaces in the title.
I think that's it. If you can even point me in the right directions to solve these I'd' be happy. Thank you!

How to inspect variables in a FAKE script?

I have a bug in my FAKE script in obscure code were I interface with legacy build infrastructure. I have a bug there and I wanted to debug my script in Visual Studio. I used --break flag to attach Visual Studio 2013 debugger and I could set up a break point. But I cannot inspect any of variables of a FAKE script.
Is there a way to use Visual Studio 2013 debugger to inspect state of FAKE script? There seems to no problems with regular F# programs.
Have you tried using the REPL to invoke your build script a bit at a time?
An example of using VS Code + the ionide plugin to use the FSI interactive Repl
You should be able to highlight and run parts of your script in the REPL.

Resources