Configuring Precompilation Options for Visual Studio

IDEs

In the Veracode Static for Visual Studio Options window, you can use the settings on the Precompilation tab to configure MSBuild and select a legacy precompilation method. You can usually accept the default values.



Precompilation and Publish Target Directory
Specifies the location of the precompilation target directory in which to publish the build artifacts. The extension saves this value to the VeracodePrecompileProfile.pubxml file, which it creates during the precompilation process.
Publish on build with Veracode settings
Select this checkbox to invoke the precompile or publish process after a build or rebuild.
Use legacy precompilation method
Select this checkbox to use the legacy method for precompiling and publishing, instead of the MSBuild method configured under the ASP.NET Publish section in the window. The MSBuild settings are saved. You can clear this checkbox to return to the MSBuild precompilation method.
Project-less templates, such as web forms applications, require that the Use legacy precompilation method checkbox is selected. The new functionality relies directly on MSBuild, which does not fully support 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 window with an empty MSBuild Directory field. See Troubleshooting Precompilation Errors if you have problems.

In general, you can use a later version of MSBuild on projects created with older versions of Visual Studio.

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

At runtime, the full path to the solution currently open in the Visual Studio solution explorer replaces the SolutionName variable. 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, if the extension does not modify the /p:PublishProfile property or find the VeracodePrecompileProfile.pubxml file in the default publish profiles directory, it always creates the VeracodePrecompileProfile.pubxml file. 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 occurs. If you modify the /p:PublishProfile property in any way, the extension no longer automatically creates the VeracodePrecompileProfile.pubxml file. 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: 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.