How to inspect variables in a FAKE script? - debugging

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.

Related

Run F# script in 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.

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?

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.

Custom Visual Studio Debug Engine for Simulator

I have a requirement for developing a debugger extension for Visual Studio. The code is in C++, however, it is run in a simulator environment. The application is capable of receiving break points and displaying variable information.
I have looked into the Concord API, but it seems rather complex. Do I have to develop an Expression Evaluator, even though the code is in C++?
Basically I just want the program to run and hit the breakpoints that the user has created for starters.
Should I try and write a visual studio extension instead? Although I don't see any way of halting execution of a program in debug mode?
Thanks
Ah the joy of writing a custom debugger! I'm writing one now. See the visual studio custom debug engine sample to start with. Python Tools for Visual Studio, MIDebugEngine are more complex but also more complete and production code. Much easier to write the debugger in C#.
Some blogs that helped me a lot.
https://limbioliong.wordpress.com/2011/08/30/creating-a-com-server-using-c/
https://blogs.msdn.microsoft.com/jmstall/2009/07/09/icustomqueryinterface-and-clr-v4/
VS2005 SDK PDF has more detailed debugger documentation.
VS2015/17 C# Extension projects has a custom project type package which comes with a script debugger launcher to start with.

Debugging IronPython in Visual Studio

I'm using Visual Studio 2012 to debug my IronPython program. I've got IronPython and PyTools installed already.
While debugging, when I hover over a variable, say tenants_path, the value that's shown is IronPython.Runtime.ClosureCell. Why is this happening?
To rectify this issue, I needed to right click on the solution, and choose Properties.
In the General tab, ensure that Interpreter is set to IronPython 2.7.
In Debug tab, ensure Launch mode: is set to Standard Python launcher.
IronPython doesn't generate debugging information for its generated code by default, so VS just does the best it can.
If you're running ipy.exe, then you should run with the -X:Debug command-line option; if you're embedding, you'll need to pass "Debug" as true when creating the engine.

Resources