Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cezarypiatek/msbuild-cheatsheet


https://github.com/cezarypiatek/msbuild-cheatsheet

Last synced: 4 days ago
JSON representation

Awesome Lists containing this project

README

        

# MsBuild cheatsheet

## Properties

### Define property

```xml

Value

```

## Collections

### Define collection

```xml


ValueX


ValueY

```
[MSBuild well-known item metadata](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata?view=vs-2019)

### Update metadata

```xml


ValueZ

```

### Remove elements

```xml

```

### Remove duplicates

```xml



fr



```

### Write elements to file

```xml

```

### Read elements from file

```xml



```

## Conditions

### Conditional Groups

```xml



$(MSBuildFrameworkToolsPath)\Microsoft.CSharp.targets
$(MsBuildFrameworkToolsPath)




$(MSBuildToolsPath)\Microsoft.CSharp.CrossTargeting.targets




$(MSBuildToolsPath)\Microsoft.CSharp.CurrentVersion.targets

```

## Targets

### Import file with targets

```xml

```

### Call another target

```xml



```

### Incremental build

The target will be skipped if the output file exists is newer than all of the input files.

```xml

```

### Run target for each element

```xml


```

### Running target if file get changed
This will run `GenerateCodeFromAttributes` target if any files that belongs to `Compile` collection get changed.

```xml


MSBuild:GenerateCodeFromAttributes

```

## Tasks

### Using task

```xml



```

### Inline task with C#

https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-inline-tasks?view=vs-2019

```xml












```

### Inline task with PowerShell

https://blogs.msdn.microsoft.com/msbuild/2010/02/20/msbuild-task-factories-guest-starring-windows-powershell/

```xml










[email protected]
[email protected];[email protected]



```

## Path's tasks

Convert path to absolute path
```xml

```

## Additional *.props and *.targets files loaded by convention

https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019