-
Notifications
You must be signed in to change notification settings - Fork 65
/
Directory.Build.targets
51 lines (50 loc) · 2.09 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<Project>
<PropertyGroup>
<TransformReadmeSource>$(MSBuildThisFileDirectory)build\TransformReadmeForNuget.cs</TransformReadmeSource>
</PropertyGroup>
<ItemGroup>
<NuGetPackInput Include="$(TransformReadmeSource)" />
</ItemGroup>
<UsingTask TaskName="TransformReadmeForNuget"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputReadmePath Required="true" />
<OutputDirPath Required="true" />
<GeneratedReadmePath Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Text" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment"
Language="cs"
Source="$(TransformReadmeSource)"/>
</Task>
</UsingTask>
<!--
NuGet don't support <img> (in particular, align, width and height).
This task generates a new README file with those unsupported constructs removed.
-->
<Target Name="GenerateNugetReadmeFiles"
BeforeTargets="GenerateNuspec"
Condition="'$(IsPackable)' == 'true'"
Inputs="@(NuGetPackInput)" Outputs="@(NuGetPackOutput)">
<TransformReadmeForNuget
InputReadmePath="README.md"
OutputDirPath="$(IntermediateOutputPath)">
<Output TaskParameter="GeneratedReadmePath"
PropertyName="NugetTransformedReadmePath" />
</TransformReadmeForNuget>
<Message Text="A new README was generated for $(MSBuildProjectName) at $(NugetTransformedReadmePath)" Importance="high" />
<ItemGroup>
<_PackageFiles Remove="README.md" />
<_PackageFiles Include="$(NugetTransformedReadmePath)">
<BuildAction>None</BuildAction>
<PackagePath>/README.md</PackagePath>
</_PackageFiles>
</ItemGroup>
</Target>
</Project>