-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Directory.Build.targets
28 lines (26 loc) · 1.36 KB
/
Directory.Build.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<Project>
<PropertyGroup>
<MSBuildTaskDllPath Condition="'$(MSBuildRuntimeType)' == 'Full'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</MSBuildTaskDllPath>
<MSBuildTaskDllPath Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</MSBuildTaskDllPath>
<MSBuildTaskFactory Condition="'$(MSBuildRuntimeType)' == 'Full'">CodeTaskFactory</MSBuildTaskFactory>
<MSBuildTaskFactory Condition="'$(MSBuildRuntimeType)' == 'Core'">RoslynCodeTaskFactory</MSBuildTaskFactory>
</PropertyGroup>
<UsingTask TaskName="ReplaceFileText" TaskFactory="$(MSBuildTaskFactory)" AssemblyFile="$(MSBuildTaskDllPath)">
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(OutputFilename,Regex.Replace(File.ReadAllText(InputFilename),MatchExpression,ReplacementText));
]]>
</Code>
</Task>
</UsingTask>
</Project>