Using Visual Studio Extension Precompilation Options

IDEs

The Precompilation Options tab includes MSBuild options and an option to select the legacy precompilation method. You can usually accept the default values on the Precompilation Options tab.



Precompilation and Publish Target Directory
Specifies the location of the precompilation target directory. It defines the target directory in which the build artifacts are published. This value is also written to the VeracodePrecompileProfile.pubxml file that is created as part of the precompilation process.
Publish on build with Veracode settings
When this option is selected, the precompile or publish mechanism is invoked after a build or rebuild.
Use legacy precompilation method
If you select this checkbox, the ASP.NET Publish section in the preferences dialog is disabled. However, all values will be retained and all precompilation is done using the legacy method. This policy is being maintained so users who do not have to change their workflow if they do not want to, and as a backup in case the new publish mechanism does not work for them but the original legacy method does.
Note: In this context, precompilation and publish have the same meaning.
Project-less templates (for example, many web forms applications) require the Use legacy precompilation method checkbox to be selected. The new functionality relies directly on MSBuild, which is not fully supported with the legacy project-less templates.
MSBuild Directory
If MSBuild is not found in any of the locations specified in the Using Standard MSBuild Paths, it displays the preferences dialog with an empty MSBuild Directory field. See Troubleshooting Precompilation Errors if you have problems.

In general, you can use a later version of MSBuild with all supported older projects, for example, projects created with Visual Studio 2012, 2013, or 2015 when using any variation of MSBuild 2017.

The only known exception is with VS 2013. If you use the newer MSBuild for 2015 (for example, MSBuild\14.0\Bin\), compilation issues occur unless you append the parameter /tv:12.0 to the end of the MSBuild Arguments field.

In the MSBuild Directory field, enter the directory path of the MSBuild version you want to use.

MSBuild Arguments
The default MSBuild arguments are:

${SolutionName} /p:DeployOnBuild=true /p:PublishProfile=VeracodePrecompileProfile

The SolutionName variable is dynamically replaced at runtime with the full path to the solution currently open in the Visual Studio solution explorer. The other two parameters are required for MSBuild to precompile the solution, and more specifically, each web project in the solution.

The last parameter /p:PublishProfile=VeracodePrecompileProfile instructs MSBuild to look for a publish profile named VeracodePrecompileProfile.pubxml in the default publish profiles directory, for example, WebProjectRoot/Properties/PublishProfiles.

By default the VeracodePrecompileProfile.pubxml file is always created if the /p:PublishProfile property is not modified and if the file is not found in the default publish profiles directory. If you want to place this file in a different location, pass the full path within quotes to the location of the file: /p:PublishProfile="C:\PublishProfiles\VeracodePrecompileProfile.pubxml".

The custom directory location and publish profile file must exist or an error will occur. If you modify the /p:PublishProfile property in any way, the extension will no longer automatically create the VeracodePrecompileProfile.pubxml file and will assume you have created this file yourself by renaming or moving it. You can click Restore to Default to revert back to the original behavior.

If you encounter problems and want more detailed information on what MSBuild is doing, you can add the logging parameter. For example, you must change the example path to an appropriate logging directory:

/flp:verbosity=detailed;logfile=C:\Logs\VeracodeMsBuildLog-${LogDateTimeStamp}.log

You must ensure the directory structure referenced in the logfile attribute exists. The filename is automatically created, but you receive an error if the directories do not already exist. Also, verify there is a space between the previous parameter and this parameter.

The LogDateTimeStamp variable at the end of the path is automatically replaced with a date and time stamp, so each time publish is invoked it creates a new file as opposed to appending to an existing file.

Note: Valid verbosity values include the following: diagnostic, detailed, normal, minimal, and quiet. The diagnostic value can create extremely large log files depending on the complexity of your solution, and Veracode recommends starting with a less-verbose option.