-
Notifications
You must be signed in to change notification settings - Fork 0
/
ManifestUpdateFile.targets
48 lines (45 loc) · 1.53 KB
/
ManifestUpdateFile.targets
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
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' ToolsVersion="12.0">
<UsingTask TaskName="UpdateManifest" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<ManifestFile ParameterType="System.String" Required="true" />
<BuildVersion ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml"/>
<Using Namespace="System.Xml"/>
<Using Namespace="System.IO"/>
<Code Type="Fragment" Language="cs"><![CDATA[
string contents = "";
using(StreamReader reader = new StreamReader(ManifestFile))
{
contents=reader.ReadToEnd();
}
string minVersion = "";
string maxVersion = "";
if(BuildVersion.Equals("v2015_Debug") || BuildVersion.Equals("v2015_Release"))
{
minVersion = "12.0";
maxVersion = "12.9";
}
else if(BuildVersion.Equals("v2014_Debug") || BuildVersion.Equals("v2014_Release"))
{
minVersion = "11.0";
maxVersion = "11.9";
}
else if(BuildVersion.Equals("v2011_Debug") || BuildVersion.Equals("v2011_Release"))
{
minVersion = "9.0";
maxVersion = "10.9";
}
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(contents);
xmlDoc["PluginPackage"]["RequiredProduct"].SetAttribute("maxversion", maxVersion);
xmlDoc["PluginPackage"]["RequiredProduct"].SetAttribute("minversion", minVersion);
XmlTextWriter wr = new XmlTextWriter(ManifestFile, Encoding.UTF8);
wr.Formatting = Formatting.Indented;
xmlDoc.Save(wr);
wr.Close();
]]></Code>
</Task>
</UsingTask>
</Project>