dotnet / dotnet/msbuild

Task for pre-processing source files

Open
#4,018 6 comments 4 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

I'd like to contribute to MSBuild a task we wrote for aspnet that I think would be generally useful. Is this something MSBuild would accept as a PR?

### GenerateFileFromTemplate

Purpose: pre-process a source file using MSBuild variables.
**Usage:**
```xml

```
**Template file example**
```
// MyFile.cs.in
public class ${ClassName}
{
public void Method${MethodName}()
{
Console.WriteLine("`${NotReplacedDueToBacktick}"");
}
}
```

**Template syntax**:
* variables in the template file use powershell/bash syntax: `${VarName}`.
* if you need a file with `${...}`, you can escape this with a backtick: `${...}

**Justification**:
WriteLinesToFile is good, but I've frequently run into problems with it when I need to write a file that has `\`, `/`, or `;` in it.

Current implementation: https://github.com/aspnet/BuildTools/blob/master/modules/BuildTools.Tasks/GenerateFileFromTemplate.cs, https://github.com/aspnet/BuildTools/blob/master/test/BuildTools.Tasks.Tests/GenerateFileFromTemplateTests.cs

cc @jeffkl @livarcocc

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.