73 строки
3.4 KiB
XML
73 строки
3.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
<UsingTask TaskName="InjectXmlLanguage" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
|
<ParameterGroup>
|
|
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
|
|
</ParameterGroup>
|
|
<Task>
|
|
<Reference Include="System" />
|
|
<Using Namespace="System.Diagnostics" />
|
|
<Using Namespace="System.IO" />
|
|
<!--
|
|
Not sure where the requirement of xml:lang="en" came from. But to address it - hacking is the only way now:
|
|
https://social.msdn.microsoft.com/forums/en-us/70b984eb-f490-4494-8fbc-12fe4a62e5e4/xmllang-on-doc-for-xml-doc-comments?forum=xmlandnetfx
|
|
-->
|
|
<Code Type="Fragment" Language="cs">
|
|
<![CDATA[
|
|
Log.LogMessage("Called InjectXmlLanguage");
|
|
foreach (var inputFilePath in InputFiles.Select(f => f.ItemSpec))
|
|
{
|
|
Log.LogMessage("Fixing {0}", inputFilePath);
|
|
string filePath = inputFilePath;
|
|
if (filePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
filePath = filePath.Substring(0, filePath.Length - 3) + "xml";
|
|
}
|
|
|
|
if (filePath.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
string[] files = null;
|
|
int starIndex = filePath.IndexOf('*');
|
|
if (starIndex >= 0)
|
|
{
|
|
string dir = filePath.Substring(0, starIndex);
|
|
if (string.IsNullOrEmpty(dir))
|
|
{
|
|
dir = ".";
|
|
}
|
|
|
|
string file = Path.GetFileName(filePath.Substring(starIndex));
|
|
files = Directory.GetFiles(dir, file, SearchOption.AllDirectories);
|
|
}
|
|
else
|
|
{
|
|
files = new[] { filePath };
|
|
}
|
|
|
|
foreach (string fileName in files)
|
|
{
|
|
if (File.Exists(fileName))
|
|
{
|
|
Log.LogMessage("Processing XML: {0}", fileName);
|
|
string text = File.ReadAllText(fileName);
|
|
text = text.Replace("<doc>", "<doc xml:lang=\"en\">");
|
|
File.WriteAllText(fileName, text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]]>
|
|
</Code>
|
|
</Task>
|
|
</UsingTask>
|
|
|
|
<Target Name="FixXmlDocumentation" AfterTargets="AfterBuild" DependsOnTargets="AfterBuild" Condition="$(OS) == 'Windows_NT'">
|
|
<InjectXmlLanguage InputFiles="$(DocumentationFile)" />
|
|
</Target>
|
|
|
|
<Target Name="AddXmlDocToNugetPackage" Condition="$(OS) == 'Windows_NT'">
|
|
<ItemGroup>
|
|
<BuildOutputInPackage Include="$(OutputPath)$(TargetName).xml" />
|
|
</ItemGroup>
|
|
</Target>
|
|
</Project> |