1
0
Форкнуть 0

Added an after build target to add a language attribute to the generated XML documentation.

This commit is contained in:
David Duffy 2016-09-02 18:47:31 -07:00
Родитель 774e175783
Коммит b2858e3d55
3 изменённых файлов: 74 добавлений и 5 удалений

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25417.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2E6DDE9E-8C75-4F9C-8906-08EBDD6E73EF}"
EndProject
@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Readme.md = Readme.md
RunTestsCore.ps1 = RunTestsCore.ps1
SetEnv.targets = SetEnv.targets
Signing.props = Signing.props
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ApplicationInsights.AspNetCore", "src\Microsoft.ApplicationInsights.AspNetCore\Microsoft.ApplicationInsights.AspNetCore.xproj", "{95EC3635-22E4-4C3A-A066-F5823A0648DA}"

Просмотреть файл

@ -21,7 +21,7 @@
<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Address ParameterType="System.String" Required="true"/>
<Address ParameterType="System.String" Required="true" />
<FileName ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
@ -90,6 +90,66 @@
</Task>
</UsingTask>
<UsingTask TaskName="InjectXmlLanguage" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<!--<InputFile ParameterType="System.String" 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="CheckBuildParameters">
<Message Importance="high" Text="ComputerName: $(ComputerName)"></Message>
<Message Importance="high" Text="User: $(USERDOMAIN)\$(USERNAME)"></Message>
@ -105,7 +165,7 @@
<Target Name="DownloadCLI">
<DownloadFile Address="https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/Latest/dotnet-dev-win-x64.latest.zip" FileName="$(CliZipFile)" />
<ExtractZipArchive InputFiles="$(CliZipFile)" OutputPath="$(CliToolsPath)" ArchiveFileNameAsRootFolder="false" Overwrite="true"/>
<ExtractZipArchive InputFiles="$(CliZipFile)" OutputPath="$(CliToolsPath)" ArchiveFileNameAsRootFolder="false" Overwrite="true" />
</Target>
<Target Name="Build" DependsOnTargets="CheckBuildParameters;DownloadCLI">
@ -135,9 +195,16 @@
<Message Importance="high" Text="Files to sign:"></Message>
<Message Importance="high" Text="--> File:%(FilesToSign.FileName)%(FilesToSign.Extension)
--> BinariesDirectory:$([System.IO.Path]::GetDirectoryName(%(FilesToSign.FullPath))) --> Authenticode:%(FilesToSign.Authenticode)"></Message>
<ItemGroup>
<DocumentationFiles Include="**\Microsoft.ApplicationInsights.AspNetCore.xml"></DocumentationFiles>
</ItemGroup>
</Target>
<Target Name="PackageNuGet" AfterTargets="SignFiles" DependsOnTargets="AfterBuild;SignFiles">
<Target Name="FixXmlDocumentation" AfterTargets="AfterBuild" DependsOnTargets="AfterBuild">
<InjectXmlLanguage InputFiles="@(DocumentationFiles)" />
</Target>
<Target Name="PackageNuGet" AfterTargets="SignFiles" DependsOnTargets="AfterBuild;FixXmlDocumentation;SignFiles">
<Exec Command='"$(CliToolsPath)\dotnet.exe" pack $(ProjectToBuild) -c $(Configuration)' ContinueOnError="ErrorAndStop" />
</Target>
</Project>

Просмотреть файл

@ -18,7 +18,8 @@
},
"buildOptions": {
"keyFile": "../../keys/35MSSharedLib1024.snk",
"delaySign": true
"delaySign": true,
"xmlDoc": true
},
"dependencies": {
"Desktop.Analyzers": "1.2.0-beta2",