powershell script to automate code coverage tests in visual studio? - powershell

Need to create a powershell script to automate code coverage tests in visual studio 2022.
Expected a properly formatted XML file to have been generated, which can then be imported into Excel for analysis.

Related

How to execute .PS1 file from Visual Studio 2017 project

I have a .PS1 file as part of Visual Studio 2017 project. Let me know, how to execute this script file in debug mode (VS debug mode)? also let me know, how to pass input variables to this script file?
Check out PowerShell Tools for Visual Studio and the PowerShell Class.

Visual Studio test task fails in pipeline but succeeds in test console

I am using Visual studio test task to run all my tests as a part of my build definition.
The options that I have enabled are as attached below:
Now, the problem here is that, some of my tests always fail when I run them from the build pipleine , however all of these test seem to pass when I run them via
vstests console.exe command.
ex: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\VSTest.Console" <path to dll>
Does anyone have any clue what could be wrong in here?
Thanks.
Using the Installed by tools installer selection, I would need to see what your tools installation task is doing to provide additional info. Maybe you're not installing a version that is compatible with the tests?
If you don't have a specific need to call out a different test platform version, maybe try using Latest.
OR
Since you're calling ...\Microsoft Visual Studio 14.0\...\VSTest.Console, you may want to select the Visual Studio 2015 option.

How to link powershell script to xaml (Visual studio for Blend)

I am new to Powershell and Visual Studio Blend.
I have created a UI using Microsoft Blend for Visual Studio which has got text box,combobox,label.
I have a Powershell script that needs to be run according to the list items in combobox.
How do I link powershell with the XAML in VS (Blend)such that if i choose a combobox the output should be displayed in the below label I have created. Basically I need to insert Powershell inside the XAML.
I have pure powershell script that executes well , i need to execute this using a GUI.

CodeAnalysis using msbuild does not fail on warning/error

I started down this path of wanting to do code analysis on my solution using msbuild. I was looking at FxCop but it appears to now be part of Visual Studio and from my understanding you need Visual Studio installed on your build agents.
I am calling msbuild from a powershell using the following command;
"$(get-content env:systemroot)\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /tv:4.0 /p:RunCodeAnalysis=Always"
It appears to run the code analysis and output warnings but never fails the build, even after I added <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
to my .csproj file.
All I want is to run code analysis from msbuild command line and have it fail the build if any warning is found. I understand it can be done in Visual Studio but I need to be able to run this from the command line (with/without VS2013)
Am I missing something? Shouldn't /p:RunCodeAnalysis=Always and setting the CodeAnalysisTreatWarningsAsErrors to true be all that is needed?

Run powershell script at startup in visual studio

I have a powershell file (script.ps1) that is in some of my visual studio solutions. The script contains utility functions for the project.
At the moment, I just open the nugget package manager and copy and paste the content of the script and it runs fine. I can run the functions correctly from the nugget package manager. But this has to be done, each time I open the solution.
Is there a way to get this handle automatically each time I open the solutions?
Rather than copy pasting the entire thing, you can dot source the file
. ".\script.ps1"