forked from microsoft/ApplicationInsights-aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirs.proj
206 lines (187 loc) · 11.2 KB
/
dirs.proj
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Signing.props"/>
<PropertyGroup>
<CliZipFile>$(BUILD_ARTIFACTSTAGINGDIRECTORY)\dotnet-dev-win-x64.latest.zip</CliZipFile>
<CliToolsPath>$(BUILD_ARTIFACTSTAGINGDIRECTORY)\dotnet-dev-win-x64.latest</CliToolsPath>
<!-- Library -->
<ProjectToBuild>.\src\Microsoft.ApplicationInsights.AspNetCore\project.json</ProjectToBuild>
</PropertyGroup>
<ItemGroup>
<!--<Solution Include="src\Microsoft.ApplicationInsights.AspNetCore\Microsoft.ApplicationInsights.AspNetCore.xproj" />-->
<!-- Tests -->
<TestProject Condition="$(RunTests) != '' And $(RunTests)" Include="test\Microsoft.ApplicationInsights.AspNetCore.Tests\ " />
<TestProject Condition="$(RunTests) != '' And $(RunTests)" Include="test\WebApiShimFw46.FunctionalTests\ " />
<TestProject Condition="$(RunTests) != '' And $(RunTests)" Include="test\EmptyApp.FunctionalTests\ " />
<TestProject Condition="$(RunTests) != '' And $(RunTests)" Include="test\MVCFramework45.FunctionalTests\ " />
</ItemGroup>
<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Address ParameterType="System.String" Required="true" />
<FileName ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
new System.Net.WebClient().DownloadFile(Address, FileName);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ExtractZipArchive" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<OutputPath ParameterType="System.String" Required="true" />
<ArchiveFileNameAsRootFolder ParameterType="System.Boolean" Required="false" />
<Overwrite ParameterType="System.Boolean" Required="false" />
</ParameterGroup>
<Task>
<Reference Include="System" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Using Namespace="System.Diagnostics" />
<Using Namespace="System.IO" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs">
<![CDATA[
foreach (var inputFilePath in InputFiles.Select(f => f.ItemSpec))
{
using (ZipArchive archive = ZipFile.OpenRead(inputFilePath))
{
string inputFileName = Path.GetFileName(inputFilePath);
if (true == ArchiveFileNameAsRootFolder && true == Overwrite)
{
DirectoryInfo archiveDirectory = new DirectoryInfo(Path.Combine(OutputPath, inputFileName));
if (true == archiveDirectory.Exists)
{
Log.LogMessage ("Archive root folder already exists, deleting path:{0}", archiveDirectory.FullName);
archiveDirectory.Delete(recursive: true);
}
}
foreach (ZipArchiveEntry entry in archive.Entries)
{
string path = ArchiveFileNameAsRootFolder
? Path.Combine(OutputPath, inputFileName, entry.FullName)
: Path.Combine(OutputPath, entry.FullName);
FileInfo fileInfo = new FileInfo(path);
DirectoryInfo directoryInfo = new DirectoryInfo(fileInfo.DirectoryName);
if (false == directoryInfo.Exists)
{
Log.LogMessage ("Creating directory for archive entry, path:{0}", directoryInfo.FullName);
directoryInfo.Create();
}
Log.LogMessage("Extracting entry to path:{0}", path);
entry.ExtractToFile(path, Overwrite);
}
}
}
]]>
</Code>
</Task>
</UsingTask>
<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 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>
<Message Importance="high" Text="RunningInMicroBuild: $(RunningInMicroBuild)"></Message>
<Message Importance="high" Text="Intermediate Output Path: $(BaseIntermediateOutputPath)"></Message>
<Message Importance="high" Text="Bin Root: $(BinRoot)"></Message>
<Message Importance="high" Text="Configuration: $(Configuration)"></Message>
<Message Importance="high" Text="CLI Zip: $(CliZipFile)"></Message>
<Message Importance="high" Text="CLI Tools Path: $(CliToolsPath)"></Message>
<Message Importance="high" Text="Run Tests: $(RunTests)"></Message>
<Message Importance="high" Text="Sign Assembly: $(SignAssembly)"></Message>
</Target>
<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" />
</Target>
<Target Name="Build" DependsOnTargets="CheckBuildParameters;DownloadCLI">
<Exec Command='"$(CliToolsPath)\dotnet.exe" --version' />
<Exec Command=".\nuget.exe locals all -clear" ContinueOnError="ErrorAndStop" />
<Exec Command='"$(CliToolsPath)\dotnet.exe" restore' ContinueOnError="ErrorAndStop" />
<Exec Command='"$(CliToolsPath)\dotnet.exe" build $(ProjectToBuild) -c $(Configuration)' ContinueOnError="ErrorAndStop" />
<Exec Condition="$(RunTests) != '' And $(RunTests)" Command='"$(CliToolsPath)\dotnet.exe" build %(TestProject.Identity) -c $(Configuration)' ContinueOnError="ErrorAndStop" />
<Message Condition="$(RunTests) != '' And $(RunTests)" Importance="high" Text="Running tests..."></Message>
<Exec Condition="$(RunTests) != '' And $(RunTests)" Command='"$(CliToolsPath)\dotnet.exe" test' WorkingDirectory='%(TestProject.Identity)' ContinueOnError="ErrorAndStop" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(BinRoot)\$(Configuration)" />
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<RemoveDir Directories="$(BUILD_ARTIFACTSTAGINGDIRECTORY)\dotnet-dev-win-x64.latest" />
<Delete Files="$(BUILD_ARTIFACTSTAGINGDIRECTORY)\dotnet-dev-win-x64.latest.zip" />
</Target>
<Target Name="AfterBuild" AfterTargets="Build" DependsOnTargets="Build">
<ItemGroup>
<FilesToSign Include="**\Microsoft.ApplicationInsights.AspNetCore.dll">
<Authenticode Condition="'%(FilesToSign.Authenticode)' == ''">Microsoft</Authenticode>
<StrongName Condition="'%(FilesToSign.StrongName)' == ''">MsSharedLib72</StrongName>
</FilesToSign>
</ItemGroup>
<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="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>