How to run Gtest in powershell with set debug environment - powershell

Currenlty I am using Visual Studio community edition and Gtest.
When I run my test using the Visual Studio debug, my test are running fine
But when I build the solution and run my test fail.
Is there a way I can pass the PATH environment to the command I am runnig?
Try to set the PATH on powershell so it would load while running the command.

Thanks to #273k I was able to solve my problem.
The reason this test did not pass on the command line, was due to this was being run on a different folder.
Once I moved the relevant support files in the same folder the test started to pass

Related

setting up visual studio code for c++, but unable to compile

I have installed visual studio 2019 which works fine for c++ but unable to create folders and sections to store multiple code files. So thought of switching to visual studio code and followed all tutorials available on youtube and documentation. But Visual studio IDE has got nothing showing up when Run Build task is initiated, which is expected to show the c++ extension downloaded. Mingw64 is installed and checked in the terminal too.
no output or terminal opened on Run
compiler installation checked
From the image attached regarding no output in the terminal or terminal opened, it looks like the exe is made because it says 'Build finsihed succesfully'. You'll need to run this executable from the terminal.
For this, if youre in the same directory all you have to do is type the filename. helloworld.exe in the cmd, if its powershell, then ./helloworld.exe. (Also note that for exe files you dont need to explicitly mention .exe at the end of the file name)
The powershell method should work on cmd too.
And if youre not in the same directory as the executable, you can either change directory by typing cd path/to/file and proceed as above, or run directly by typing path/to/file/helloworld.exe. where path/to/file is the directory of your helloworld.exe file

MSBuild weird behavior when run inside a script

I have some PS scripts that I use for SVN tagging / releasing applications.
Usually its working fine, everything is built as I want to.
Few days ago, I'm told to make a fresh release of some older application.
So I tried leveraging my scripts for that purpose. So far so good.
The problem I'm facing now: Somehow, when MSBuild is called inside my script, its giving me errors
The thing is, when I execute the same command outside the script in a PS console, its building without errors.
The call: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\msbuild.exe solution.sln /t:Build /p:Configuration=Release /m /v:q /clp:Summary /nologo
Any suggestions are appreciated.
Apparently it has to do with PackageReference on older projects..
https://github.com/dotnet/sdk/issues/8100 my workaround is to build in VS first then use my script without restore or clean.
So I got my release.

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.

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?

Running PowerShell script on debugging project

I have a C# project that relies on a few services. I've written a PowerShell script that checks if the services are running and starts them if they're not. I'm currently running the script manually, but it would be better if I could configure Visual Studio to run the script every time I start debugging the project.
I experimented with using the post-build events, but that only works (obviously) when the project has been changed and needs to be rebuilt. If there is a solution that allows me to run the PowerShell script regardless of whether the project is being rebuilt, that would be excellent.
I had a similar requirement. This is what i did:
Installed the powershell tools from the Visual Studio 2013 gallery
Added a project to the solution of the (newly installed) Powershell Project type
Added a Powershell script to start the services (in my case a Redis Server)
Added this project to the solution "set startup projects" (right-click on the Solution Explorer top level solution node) using the multiple startup projects setting