ReSharper Help

MSBuild

MSBuild is a platform that is widely used for building applications. Using specific XML tags, you can define how your project should be built or executed. Using ReSharper you can do it faster.

If necessary, you can disable support of ReSharper features in build script files by clearing the corresponding check box in the Environment | Products & Feature options page.

Code highlighting

If you mistype names of predefined elements or their attributes, ReSharper informs you about such mismatch via highlighting.

ReSharper_by_Language__MSBuild__Code_Highlighting_02

If you try to reference the property that is not yet defined, ReSharper detects such cases as well.
ReSharper_by_Language__MSBuild__Code_Highlighting_01

You can find the list of available inspections on the Inspection Severity page of the Options dialog box. To do this, choose ReSharper | Options | Code Inspections | Inspection Severity, then click the MSBuild tab.
ReSharper_by_Language__MSBuild__Highlighting__Inspection_Severity

Pay attention, that some inspections are defined for both platforms: NAnt and MSBuild. If you change the severity level for the Missing required attribute inspection, for example, the severity level changes for both platforms. It is not possible to configure such inspections independently.

Code completion

Code completion features are helpful when you start typing predefined elements and their attributes. ReSharper completes them, you save your time.

ReSharper_by_Language__MSBuild__Code_Completion_01

If you have custom elements and they are properly referenced, ReSharper also suggests them.
ReSharper_by_Language__MSBuild__Code_Completion_02

ReSharper provides code completion capabilities for MSBuild and NAnt scripts. It suggests tags, their attributes, properties, item groups and metadata names.
Coding_Assistance__Code_Completion__Symbol__build_scripts_01
ReSharper distinguishes required elements and adds special icon, so you can easily find them in the completion list. The list includes all symbols visible in the current scope, so pick an item from the list or continue typing to narrow down the scope.
Coding_Assistance__Code_Completion__Symbol__build_scripts_02
To invoke the completion list in NAnt scripts, press Ctrl+Space or select ReSharper | Edit | Complete Symbol. In MSBuild scripts ReSharper does it for you, automatically.
In the completion list you see special icons. They help you distinguish between the types of suggested items.

ThemedIcon.PropertyGroup.Screen.[Gray] represents the PropertyGroup element only
ThemedIcon.Attribute.Screen.[Gray] represents attributes of elements
ThemedIcon.ItemGroup.Screen.[Gray] represents the ItemGroup element and its items
ThemedIcon.Property.Screen.[Gray] represents properties
ThemedIcon.Target.Screen.[Gray] represents the Target element and targets
ThemedIcon.Task.Screen.[Gray] represents tasks
ThemedIcon.UsingTask.Screen.[Gray] represents the UsingTask element only
ThemedIcon.Element.Screen.[Gray] represents all other structure elements

Examples of quick-fixes

Define property
If you have not defined the property yet, but want to, use the quick-fix. ReSharper adds a new markup element with the corresponding name above the usage.

ReSharper_by_Language__MSBuild__Quick-Fixes__define_property_01

Add required attribute
If for some reason you have not added required attributes or even do not remember what attributes are obligatory for an element, do not bother. ReSharper highlights such elements and suggests the quick-fix to fix the problem.

ReSharper_by_Language__MSBuild__Quick-Fixes__add_attribute_01

Navigation

To get a general idea about the structure of your build file, use the File Structure window. You can also double-click an element to navigate directly from the tree to its declaration in source code.

ReSharper_by_Language__MSBuild__File_Structure

Use Navigate To features to jump to the declaration of a symbol or move through found usages.
ReSharper_by_Language__MSBuild__Navigate_To

Search

ReSharper can find usages of properties, item groups and targets. All found usages are listed in the Find Results window.

ReSharper_by_Language__MSBuild__Find_Usages

Refactorings

You can easily rename an element and get its usages updated correspondingly. For more information about the refactoring, see Rename.

ReSharper_by_Language__MSBuild__Refactorings__Rename_01

You can delete elements safely. Before removing an element ReSharper performs a check whether the element has usages or not. If there are usages, they will be listed so that you can make necessary changes or discard the refactoring. For more information about the refactoring, see Safe Delete.

See Also

Last modified: 3 September 2015