This repository has been archived by the owner on Sep 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.proj
229 lines (192 loc) · 9.11 KB
/
build.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Zip>Lib\7za.exe</Zip>
</PropertyGroup>
<ItemGroup>
<Vsix Include="Vsix\*.vsix" />
</ItemGroup>
<Target Name="Build" DependsOnTargets="ExtractManifest">
<Message Text="Generating gallery feed containing:" Importance="high" />
<Message Text=" %(Entry.Identity)" Importance="high" />
<GenerateFeed Id="MobileEssentials" Title="Mobile Essentials Gallery" FeedFile="feed.atom" Entries="@(Entry)" />
</Target>
<Target Name="ExtractManifest" Inputs="@(Vsix)" Outputs="%(Identity)--BATCH">
<Message Text="Processing @(Vsix)" Importance="high" />
<Exec Command="$(Zip) e -y -oVsix @(Vsix) extension.vsixmanifest > Lib\null" />
<PropertyGroup>
<Vsix2011><Namespace Prefix='vs' Uri='http://schemas.microsoft.com/developer/vsx-schema/2011'/></Vsix2011>
<Vsix2010><Namespace Prefix='vs' Uri='http://schemas.microsoft.com/developer/vsx-schema/2010'/></Vsix2010>
</PropertyGroup>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:Identity/@Id">
<Output TaskParameter="Result" PropertyName="Id" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/@Id"
Condition="'$(Id)' == ''">
<Output TaskParameter="Result" PropertyName="Id" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:Identity/@Version">
<Output TaskParameter="Result" PropertyName="Version" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/vs:Version/text()"
Condition="'$(Version)' == ''">
<Output TaskParameter="Result" PropertyName="Version" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:Identity/@Publisher">
<Output TaskParameter="Result" PropertyName="Author" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/vs:Author/text()"
Condition="'$(Author)' == ''">
<Output TaskParameter="Result" PropertyName="Author" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:DisplayName/text()">
<Output TaskParameter="Result" PropertyName="Name" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/vs:Name/text()"
Condition="'$(Name)' == ''">
<Output TaskParameter="Result" PropertyName="Name" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:Description/text()">
<Output TaskParameter="Result" PropertyName="Description" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/vs:Description/text()"
Condition="'$(Description)' == ''">
<Output TaskParameter="Result" PropertyName="Description" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:Icon/text()">
<Output TaskParameter="Result" PropertyName="Icon" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/vs:Icon/text()"
Condition="'$(Icon)' == ''">
<Output TaskParameter="Result" PropertyName="Icon" />
</XmlPeek>
<!-- If we got an icon, move it to the final destination alongside the vsix -->
<PropertyGroup Condition="'$(Icon)' != ''">
<IconExtension>$([System.IO.Path]::GetExtension($(Icon)))</IconExtension>
<IconFile>@(Vsix -> '%(FileName)$(IconExtension)')</IconFile>
</PropertyGroup>
<XmlPeek Namespaces="$(Vsix2011)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:PackageManifest/vs:Metadata/vs:PreviewImage/text()">
<Output TaskParameter="Result" PropertyName="PreviewImage" />
</XmlPeek>
<XmlPeek Namespaces="$(Vsix2010)"
XmlInputPath="Vsix\extension.vsixmanifest"
Query="/vs:Vsix/vs:Identifier/vs:PreviewImage/text()"
Condition="'$(PreviewImage)' == ''">
<Output TaskParameter="Result" PropertyName="PreviewImage" />
</XmlPeek>
<!-- If we got a preview image, move it to the final destination alongside the vsix -->
<PropertyGroup Condition="'$(PreviewImage)' != ''">
<PreviewExtension>$([System.IO.Path]::GetExtension($(PreviewImage)))</PreviewExtension>
<PreviewFile>@(Vsix -> '%(FileName)$(PreviewExtension)')</PreviewFile>
</PropertyGroup>
<Move SourceFiles="Vsix\extension.vsixmanifest" DestinationFiles="@(Vsix -> '%(RelativeDir)%(FileName).vsixmanifest')" />
<Exec Command="$(Zip) e -y -oVsix @(Vsix) $(Icon) > Lib\null" Condition="'$(Icon)' != ''" />
<Exec Command="$(Zip) e -y -oVsix @(Vsix) $(PreviewImage) > Lib\null" Condition="'$(PreviewImage)' != ''" />
<Move SourceFiles="Vsix\$(Icon)" DestinationFiles="Vsix\$(IconFile)" Condition="'$(Icon)' != '' and Exists('Vsix\$(Icon)')" />
<Move SourceFiles="Vsix\$(PreviewImage)" DestinationFiles="Vsix\$(PreviewFile)" Condition="'$(PreviewImage)' != '' and Exists('Vsix\$(PreviewImage)')" />
<ItemGroup>
<Entry Include="$(Id)">
<Author>$(Author)</Author>
<Name>$(Name)</Name>
<Description>$(Description)</Description>
<Icon>Vsix/$(IconFile)</Icon>
<Preview>Vsix/$(PreviewFile)</Preview>
<Version>$(Version)</Version>
<Updated>@(Vsix -> '%(ModifiedTime)')</Updated>
<Payload>http://gallery.mobileessentials.org/Vsix/@(Vsix -> '%(Filename)%(Extension)')?dt=$(Name) (v$(Version))</Payload>
</Entry>
</ItemGroup>
</Target>
<PropertyGroup>
<CodeTaskAssembly Condition="'$(MSBuildAssemblyVersion)' == ''">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</CodeTaskAssembly>
<!-- In VS2013, the assembly contains the VS version. -->
<CodeTaskAssembly Condition="'$(MSBuildAssemblyVersion)' == '12.0'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll</CodeTaskAssembly>
<!-- In VS2015+, the assembly was renamed, hopefully this will be the last condition! -->
<CodeTaskAssembly Condition="'$(MSBuildAssemblyVersion)' != '' and '$(MSBuildAssemblyVersion)' >= '14.0'">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</CodeTaskAssembly>
</PropertyGroup>
<UsingTask TaskName="GenerateFeed" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskAssembly)">
<ParameterGroup>
<Id Required="true" />
<Title Required="true" />
<FeedFile Required="true" />
<Entries ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Using Namespace="System.Collections.Generic" />
<Using Namespace="System.Globalization" />
<Using Namespace="System.IO" />
<Using Namespace="System.Xml" />
<Using Namespace="System.Xml.Linq" />
<Using Namespace="System.Linq" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var ns = XNamespace.Get ("http://www.w3.org/2005/Atom");
var vsx = XNamespace.Get ("http://schemas.microsoft.com/developer/vsx-syndication-schema/2010");
foreach (var entry in Entries) {
entry.SetMetadata ("Updated", DateTime.ParseExact (entry.GetMetadata ("Updated"), "yyyy-MM-dd HH:mm:ss.fffffff", CultureInfo.CurrentCulture).ToUniversalTime ().ToString ("o"));
}
var sorted = Entries.OrderByDescending (i => i.GetMetadata ("Updated")).ToList ();
var doc = new XDocument (
new XElement (ns + "feed",
new XElement (ns + "title", Title),
new XElement (ns + "id", Id),
new XElement (ns + "updated", DateTimeOffset.UtcNow.ToString ("o")),
sorted.Select (entry =>
new XElement (ns + "entry",
new XElement (ns + "id", entry.ItemSpec),
new XElement (ns + "title", entry.GetMetadata ("Name")),
new XElement (ns + "summary", entry.GetMetadata ("Description")),
new XElement (ns + "published", entry.GetMetadata ("Updated")),
new XElement (ns + "updated", entry.GetMetadata ("Updated")),
new XElement (ns + "author", new XElement (ns + "name", entry.GetMetadata ("Author"))),
new XElement (ns + "link",
new XAttribute ("rel", "icon"),
new XAttribute ("href", entry.GetMetadata ("Icon"))),
new XElement (ns + "link",
new XAttribute ("rel", "previewimage"),
new XAttribute ("href", entry.GetMetadata ("Preview"))),
new XElement (ns + "content",
new XAttribute ("type", "application/octet-stream"),
new XAttribute ("src", entry.GetMetadata ("Payload"))),
new XElement (vsx + "Vsix",
new XElement (vsx + "Id", entry.ItemSpec),
new XElement (vsx + "Version", entry.GetMetadata ("Version")),
new XElement (vsx + "References")
)
)
)
)
);
doc.Save (FeedFile);
]]>
</Code>
</Task>
</UsingTask>
</Project>