ReSharper by Language: 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.
tip
You can disable ReSharper features in build script files by clearing the MSBuild and NAnt checkbox on the Environment | Products & Features page of ReSharper options Alt+R, O.
If you mistype names of predefined elements or their attributes, ReSharper informs you about such mismatch via highlighting.
![ReSharper: Error highlighting in MSBuild ReSharper: Error highlighting in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Code_Highlighting_02.png)
If you try to reference the property that is not yet defined, ReSharper detects such cases as well.
![ReSharper: Warning highlighting in MSBuild ReSharper: Warning highlighting in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Code_Highlighting_01.png)
To look through the list of available inspections for MSBuild, open the Code Inspection | Inspection Severity page of ReSharper options Alt+R, O, and then expand the MSBuild node.
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: 'Define property' quick-fix in MSBuild ReSharper: 'Define property' quick-fix in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Quick-Fixes__define_property_01.png)
If 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: 'Add required attribute' quick-fix in MSBuild ReSharper: 'Add required attribute' quick-fix in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Quick-Fixes__add_attribute_01.png)
You can reformat MSBuild files according to your XML formatting styles.
Code completion features are helpful when you start typing predefined elements and their attributes. ReSharper completes them, you save your time.
![ReSharper: Code completion in MSBuild ReSharper: Code completion in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Code_Completion_01.png)
If you have custom elements and they are properly referenced, ReSharper also suggests them.
![ReSharper: Code completion in MSBuild ReSharper: Code completion in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Code_Completion_02.png)
ReSharper provides code completion capabilities for MSBuild and NAnt scripts. It suggests tags, their attributes, properties, item groups and metadata names.
![ReSharper: Code completion in MSBuild ReSharper: Code completion in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/Coding_Assistance__Code_Completion__Symbol__build_scripts_01.png)
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.
![ReSharper: Code completion in MSBuild ReSharper: Code completion in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/Coding_Assistance__Code_Completion__Symbol__build_scripts_02.png)
To invoke the completion list in NAnt scripts, press CtrlSpace or select ReSharper | Edit | Complete Symbol from the main menu. In MSBuild scripts ReSharper does it for you, automatically.
In the completion list, use the following icons to distinguish between the types of suggested items.
represents the | |
---|---|
represents attributes of elements | |
represents the | |
represents properties | |
represents the | |
represents tasks | |
represents the | |
represents all other structure elements |
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: File Structure for MSBuild ReSharper: File Structure for MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__File_Structure.png)
Use Navigate To features to jump to the declaration of a symbol or move through found usages.
![ReSharper: 'Navigate To' in MSBuild ReSharper: 'Navigate To' in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Navigate_To.png)
ReSharper can find usages of properties, item groups and targets. All found usages are listed in the Find Results window.
![ReSharper: 'Find Usages' in MSBuild ReSharper: 'Find Usages' in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Find_Usages.png)
You can easily rename an element and get its usages updated correspondingly.
![ReSharper: 'Rename' refactoring in MSBuild ReSharper: 'Rename' refactoring in MSBuild](https://resources.jetbrains.com/help/img/dotnet/2024.3/ReSharper_by_Language__MSBuild__Refactorings__Rename_01.png)
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.