automate running cppcheck in tfs builds - visual-studio

I want to make cppcheck a part of the build process for tfs builds. Is adding a command to the prebuild script the only way to run it? I am using PowerShell scripts and I added the line:
Start-Process -FilePath 'C:\Program Files (x86)\Cppcheck\cppcheck.exe' -ArgumentList $("--xml-version=2 . 2> cppcheck.xml") -NoNewWindow -Wait -WorkingDirectory $projectDirectory
However I cannot test it without checking in my changes into Git project. Also running this from Visual Studio 2013, where would I see the results of this check?

Related

powershell execution policy change issue

i cannot run my project file scripts in visual studio because of this policy
its not even changing to REmoteSigned even for that command am getting same error.

Why doesn't the Visual Studio 2017 Build Tools installer work?

I have Windows running in a VMware VM, to which I connect via SSH. I can run a Command Prompt or a PowerShell. I'm trying to follow the instructions to install Visual Studio 2017 Build Tools from a command line. I download the installer from https://aka.ms/vs/15/release/vs_buildtools.exe and name it vsbt2017.exe, the "installation channel" from https://aka.ms/vs/15/release/channel and name it vs2017.chman, and I create an empty directory for the installation at C:\vs2017.
When I try this command in Command Prompt, it does not return immediately, waits a few seconds, then returns. My install path remains empty. No error message is printed to the terminal. %ERRORLEVEL% is 1.
start /wait .\vsbt2017.exe --quiet --wait --norestart --nocache --installPath C:\vs2017 --channelUri C:\vs2017.chman --installChannelUri C:\vs2017.chman --add "Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
When I try this command in PowerShell, I get the same results. The analog of this command works for me for VSBT 2019, so it's really puzzling why it doesn't work for 2017.
Start-Process -FilePath C:\vsbt2017.exe -ArgumentList "--quiet --wait --norestart --nocache --installPath C:\vs2017 --channelUri C:\vs2017.chman --installChannelUri C:\vs2017.chman --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended" -Wait -PassThru
If it makes a difference, I already have VSBT 2019 installed on this VM, but I've read in Microsoft's documentation that multiple versions can be installed simultaneously.
Almost two years ago, I asked a similar question about the 2019 Build Tools installer. This time, I need to install the 2017 Build Tools. The reason is that I need to figure out why someone else's installation of Visual Studio 2017 doesn't work, so I need to test with their version. "Just install Visual Studio 2019" is not an acceptable answer to this question.

How to update Visual Studio 2017 using command line?

I'd like to automatically update my Visual Studio 2017 installation from a script (running this script at session login).
vs_installer shows a bunch of command line arguments (using /?). So I tried :
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" update --passive --norestart
However, nothing happens. I see the process in the task manager for a few seconds, but the product is not updated.
How to update my VS installation ?
Is is possible to handle the installer update ?
PS: if possible, I'd to have a passive update, not an invisible update. I'd prefer seeing the product being updated to avoid launching a new instance while the update is in progress.
I found partially the answer. I have to specify the install path of visual studio to let the installer knows what to update:
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" update --passive --norestart --installpath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise" (assuming default path).
I still have to look for updates of the installer itself, but since I've the latest version, I've to wait for a new release.
[Edit 04/10/2019] The update process is similar with VS 2019 (at least from 16.0 to 16.0.1). I can update both version using :
Start-Process -Wait -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList "update --passive --norestart --installpath ""C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"""
Start-Process -Wait -FilePath "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList "update --passive --norestart --installpath ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"""
I use Start-Process with -Wait to avoid returning control before the end of the update.

Automate nuget update-package operation on many VS solutions

I've got 10+ Visual Studio solutions that are referencing a nuget package.
When I decide to update that package in every solution it's a very long work to open each solution manually, update its package and check-in all changes to TFS. I'd like to "automate" this process with a batch operation that does it on behalf of me.
I've made some experiments with nuget.exe by command line but it doesn't care about TFS read-only files: it overwrites the content of my files without checking-out them so this way seems not the best way to do it.
Any other suggestion to achieve the aim?
You can use nuget update command to do this. VS/TFS can detect the changes even thought you are running the command outside from VS. And usually, only "packages.config" file will be updated during the nuget package update.
Update:
Following is a simple code to find the solution files under the given path and update the nuget packages for the solution and then check in the pending changes via TFS PowerShell CommandLets (You need to install "TFS Power Tool" to use this commandlet). You can update according to your scenario.
param([String]$dirpath)
add-pssnapin Microsoft.TeamFoundation.PowerShell;
Get-ChildItem -Path $dirpath -Filter *.sln -Recurse | ForEach-Object { & nuget update $_.FullName 2>1; cd $_.Directory; get-tfspendingchange; new-tfschangeset}
Save the code as a powershell script and run it from Windows PowerShell with argument "-dirpath yoursolutionpath". It will run as following:
Download Nuget Comanline
nuget.exe restore YourSolution.sln
nuget.exe update YourSolution.sln
Nuget Docs

PowerShell CmdLet as Visual Studio External Tool

I am attempting to add a PowerShell cmdlet as an external tool in Visual Studio 2010, but whenever I call the external tool I get:
{foo} cannot be loaded because the
execution of scripts is disabled on
this system. Please see "get-help
about_signing" for more details.
I have already set my system's execution policy to 'RemoteSigned' (I also tried 'Bypass'), so why is this happening? I am fully able to run that same script if I open up a command line and call it via powershell.exe path\to\script.ps1 (which is exactly what my external tool definition is calling).
Are you running on a x64 system? If so, you have to set the execution for both x86 and x64 PowerShell. You can also pass the ExecutionPolicy directly as a parameter to Powershell (2.0) via the command line:
powershell.exe -ExecutionPolicy RemoteSigned -Command "&{ foo }"

Resources