Added targets to update the XML docs post build with a language attribute.
This commit is contained in:
Родитель
b99174cdde
Коммит
1cf308b0b8
|
@ -0,0 +1,65 @@
|
|||
<?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" />
|
||||
<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[] directories = Directory.GetDirectories("");
|
||||
//string[] files = Directory.GetFiles(Path.GetDirectoryName(filePath));
|
||||
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">
|
||||
<InjectXmlLanguage InputFiles="$(DocumentationFile)" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -2,5 +2,6 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Import Project="Signing.targets" />
|
||||
<Import Project="AddXmlLanguage.targets" />
|
||||
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче