>
>
Unattended deployment of PVS-Studio


Unattended deployment of PVS-Studio

In this article we describe working in the Windows environment. Working in the Linux environment is described in the article "How to run PVS-Studio on Linux".

Unattended deployment

As for most of other software setting up PVS-Studio requires administrative privileges.

Unattended setup is performed by specifying command line parameters, for example:

PVS-Studio_Setup.exe /verysilent /suppressmsgboxes 
/norestart /nocloseapplications

PVS-Studio may require a reboot if, for example, files that require update are locked. To install PVS-Studio without reboot, use the 'NORESTART' flag. Please also note that if PVS-Studio installer is started in a silent mode without this flag, the computer may be rebooted without any warnings or dialogs.

By default, all available PVS-Studio components will be installed. In case this is undesirable, the required components can be selected by the 'COMPONENTS' switch (following is a list of all possible components):

PVS-Studio_setup.exe /verysilent /suppressmsgboxes 
/nocloseapplications /norestart /components= Core, 
Standalone,MSVS,MSVS\2010,MSVS\2012,MSVS\2013,MSVS\2015,MSVS\2017,
MSVS\2019,MSVS\2022,IDEA,JavaCore,Rider,CLion,VSCode,DOTNET

You can install plugins for all Visual Studio versions simultaneously using the following syntax - /components="Core,*MSVS".

Brief description of components:

  • the 'Core' component is mandatory and provides the essential utilities for analyzing C, C++, and C# projects. It's required for the correct functioning of IDE extensions.
  • components with 'MSVS' prefix in their name are corresponding to Microsoft Visual Studio plug-in extensions;
  • the Standalone component installs compiler monitoring system, which allows to analyze any kind of C, C++ project as long as such project uses one of the supported compilers;
  • the 'IDEA' component corresponds to the PVS-Studio plugin for the IntelliJ IDEA development environment;
  • the 'JavaCore' component corresponds to the analyzer core for Java;
  • the 'Rider' component corresponds to the PVS-Studio plugin for the Rider development environment;
  • The 'VSCode' component corresponds to the PVS-Studio plugin for the Visual Studio Code editor;
  • The 'DOTNET' component installs the .NET SDK package of the latest supported PVS-Studio version if it is not found on your computer. It is required to analyze .NET and SDK-style .NET Framework projects. This component is available starting from PVS-Studio 7.34.

During installation of PVS-Studio all instances of Visual Studio / IntelliJ IDEA / Rider should be shut down, however to prevent user's data loss PVS-Studio does not shut down Visual Studio / IntelliJ IDEA / Rider.

The installer will exit with '100' if it is unable to install the extension (*.vsix) for any of the selected versions of Visual Studio.

Use 'HELP' to get additional information about the flags:

PVS-Studio_setup.exe /help

The PVS-Studio-Updater.exe can perform check for analyzer updates, and, if an update is available, it can download it and perform an installation on a local system. To start the updater tool "silently", the same arguments can be utilized:

PVS-Studio-Updater.exe /VERYSILENT /SUPPRESSMSGBOXES

If there are no updates on the server, the updater will exit with the code '0'. As PVS-Studio-Updater.exe performs a local deployment of PVS-Studio, devenv.exe should not be running at the time of the update as well.

If you connect to Internet via a proxy with authentication, PVS-Studio-Updater.exe will prompt you for proxy credentials. If the proxy credentials are correct, PVS-Studio-Updater.exe will save them in the Windows Credential Manager and will use these credentials to check for updates in future. If you want to use the utility with proxy without authorization you can do it using proxy flag (/proxy=ip:port).

Configuring an update source

Starting from version 7.24 PVS-Studio for Windows supports changing of an update source. This can be useful if you do not want the developers to update PVS-Studio right after the release.

For example, you can create a group of users who will receive the updates first and a group of users who should receive the updates after the first group has tested the product.

For the first group no configuration changes are required, they will receive updates from the PVS-Studio release channel.

For the second group, an alternative update channel should be deployed. All you need to do is to place version.xml file and PVS-Studio distribution package on your server. After that you should change the update source on the second group's developer machines.

The update source information is stored in the system registry: 'HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ProgramVerificationSystems\PVS-Studio' in the 'UpdateUrl' key. By default, the standard address to the version.xml file is written there, the file contains the information about an update. You can specify address to alternative version.xml file located on your server. For example: https://myserver.com/version.xml

The version.xml file has the following structure:

<ApplicationUpdate>
<!--PVS-Studio update version-->
<Version>7.23</Version>
<!--Link to download-->
<FileURL>https://myserver.com/PVS-Studio_setup.exe</FileURL>
<CompatibilityVersion>1</CompatibilityVersion>
</ApplicationUpdate>

PVS-Studio will now check for updates via the version.xml file which is stored on the myserver.com server, and if there is an update, it will download it from this server.

Installation using the Chocolatey package manager

Another possible installation option is to use the Chocolatey package manager. When using this installation option, the package manager itself has to already be installed.

The installation command of the latest available PVS-Studio package version:

choco install pvs-studio

The installation command of a specific PVS-Studio package version:

choco install pvs-studio --version=7.05.35617.2075

When installing the package, you can also set the list of installed components in a similar way to those listed in the section "Unattended deployment" of this document. To specify components, use the flag '‑‑package-parameters'. The components are equivalent to those described above and differ only in the syntax of some parameters:

  • Standalone;
  • JavaCore;
  • IDEA;
  • Rider;
  • MSVS2010;
  • MSVS2012;
  • MSVS2013;
  • MSVS2015;
  • MSVS2017;
  • MSVS2019.

Only the 'Core' component is installed by default. When listing the installation components, there is no need to specify 'Core'.

Here's the example of the command which the analyzer will install with the components 'Core' and 'Standalone':

choco install pvs-studio --package-parameters="'/Standalone'"

Deploying licenses and customizing settings

Different ways to enter the license when using various environments are covered in the documentation section "How to enter the PVS-Studio license and what's the next move".

If you want deploy PVS-Studio for many computers then you can install license without manual entering. It should place valid 'Settings.xml' file into folder under user's profile.

If many users share one desktop each one should have its own license.

Default settings location is the following:

%USERPROFILE%\AppData\Roaming\PVS-Studio\Settings.xml

It is user-editable xml file, but it also could be edited by through PVS-Studio IDE plugin on a target machine. Please note that all settings that should be kept as default values could be omitted from 'Setting.xml' file.

Deploying the analyzer without installation

PVS-Studio's functionality highly depends on the development environment where it is used. This means, without pre-configuration, the analyzer cannot be used as a fully portable tool. However, sometimes several machines have the same development environment that is necessary for the analyzer to work correctly. In this case you can copy the analyzers' files from one computer to another one. This allows you to use PVS-Studio on different computers without installing the analyzer on any of them.

You can also upload the analyzer's files to your version control system. This facilitates deploying and updating PVS-Studio on a large number of machines.

Deploying the analyzer for C, C++, and C# on Windows

Step 1. Download the PVS-Studio installer (.exe) from the website and run it.

Step 2. After the installation is complete, enter the license as specified in the documentation.

Step 3. Copy the 'C:\Program Files (x86)\PVS-Studio' folder and the 'Settings.xml' settings file to another computer. By default, the settings file is located here:

%USERPROFILE%\AppData\Roaming\PVS-Studio\Settings.xml

As a result, you will be able to run 'PVS-Studio_Cmd.exe' from the folder you've copied to the user computer. When starting the analysis, pass the settings file path to the '-s' parameter:

PVS-Studio_Cmd.exe .... -s <pathToSettingsXml> ....

Configuring PVS-Studio's portable mode on Windows for Java

Step 1. Download the PVS-Studio installer (.exe) from the website and run it;

Step 2. Create the 'PVS-Studio.lic' file with license data next to the Java analyzer's core. Use this path: 'C:\Program Files (x86)\PVS-Studio-Java'. The license file must contain the user name and the license serial number - on separate lines. For example:

UserName
XXXX-XXXX-XXXX-XXXX

After this, you can copy the 'C:\Program Files (x86)\PVS-Studio-Java' folder to a different computer that has Java 8 or higher installed. Now you can run the Java analyzer from the folder you copied. To do this, pass the license file path to the '‑‑license-path' argument:

java -jar pvs-studio.jar .... --license-path PVS-Studio.lic ....