-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathToolsForVisualStudio.targets
139 lines (122 loc) · 5.91 KB
/
ToolsForVisualStudio.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
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
<?xml version="1.0" encoding="utf-8" ?>
<!--
Deployment Framework for BizTalk Tools for Visual Studio
Copyright (C) 2008-Present Thomas F. Abraham. All Rights Reserved.
Licensed under the MIT License. See License.txt in the project root.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Build">
<PropertyGroup>
<VsixVersion>2.0.1.0</VsixVersion>
</PropertyGroup>
<PropertyGroup>
<BuildDependsOn>
UpdateCommonAssemblyInfo;
BuildAddinPackage;
BuildAddin;
RevertCommonAssemblyInfo;
CopyAddin
</BuildDependsOn>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
<Target Name="UpdateCommonAssemblyInfo">
<ReplaceAssemblyVersionInFile Path="src\CommonAssemblyInfo.cs" NewVersion="$(VsixVersion)" />
</Target>
<Target Name="RevertCommonAssemblyInfo">
<ReplaceAssemblyVersionInFile Path="src\CommonAssemblyInfo.cs" NewVersion="1.0.0.0" />
</Target>
<Target Name="BuildAddinPackage">
<WriteXmlValue XmlFilename="src\Addin.ProjectTemplate\DFBT.vstemplate" XPath="//ns:Assembly" Namespace="http://schemas.microsoft.com/developer/vstemplate/2005" Value="DeploymentFxForBizTalkAddin.ProjectWizard, Version=$(VsixVersion), Culture=neutral, PublicKeyToken=e748234cd372cc72" />
<Delete Files="src\Addin\ProjectTemplates\DFBTProject.zip" />
<Delete Files="src\Addin\bin\Release\ProjectTemplates\DFBTProject.zip" />
<Exec Command="..\..\Tools\7za a -tzip ..\Addin\ProjectTemplates\DFBTProject.zip *" WorkingDirectory="src\Addin.ProjectTemplate" />
</Target>
<Target Name="BuildAddin">
<WriteXmlValue XmlFilename="src\Addin.VS2010\source.extension.vsixmanifest" XPath="//ns:Version" Namespace="http://schemas.microsoft.com/developer/vsx-schema/2010" Value="$(VsixVersion)" />
<WriteXmlValue XmlFilename="src\Addin.VS2012\source.extension.vsixmanifest" XPath="//ns:Metadata/ns:Identity/@Version" Namespace="http://schemas.microsoft.com/developer/vsx-schema/2011" Value="$(VsixVersion)" />
<WriteXmlValue XmlFilename="src\Addin.VS2013\source.extension.vsixmanifest" XPath="//ns:Metadata/ns:Identity/@Version" Namespace="http://schemas.microsoft.com/developer/vsx-schema/2011" Value="$(VsixVersion)" />
<WriteXmlValue XmlFilename="src\Addin.VS2015\source.extension.vsixmanifest" XPath="//ns:Metadata/ns:Identity/@Version" Namespace="http://schemas.microsoft.com/developer/vsx-schema/2011" Value="$(VsixVersion)" />
<MSBuild Projects="src\DeploymentFrameworkForBizTalkAddin.sln" Properties="Configuration=Release;Platform=Any CPU" Targets="Rebuild" />
</Target>
<Target Name="CopyAddin">
<ItemGroup>
<VsixFile Include="src\AddIn.VS2010\bin\release\DeploymentFrameworkForBizTalkToolsForVS2010.vsix" />
<VsixFile Include="src\AddIn.VS2012\bin\release\DeploymentFrameworkForBizTalkToolsForVS2012.vsix" />
<VsixFile Include="src\AddIn.VS2013\bin\release\DeploymentFrameworkForBizTalkToolsForVS2013.vsix" />
<VsixFile Include="src\AddIn.VS2015\bin\release\DeploymentFrameworkForBizTalkToolsForVS2015.vsix" />
</ItemGroup>
<RemoveDir Directories="VSIX" />
<MakeDir Directories="VSIX" />
<Copy SourceFiles="@(VsixFile)" DestinationFolder="VSIX" />
</Target>
<UsingTask TaskName="ReplaceAssemblyVersionInFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<Path ParameterType="System.String" Required="true" />
<NewVersion ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
System.IO.File.SetAttributes(Path, System.IO.FileAttributes.Normal);
string contents = System.IO.File.ReadAllText(Path);
contents = System.Text.RegularExpressions.Regex.Replace(contents, @"\d+\.\d+\.\d+\.\d+", NewVersion);
System.IO.File.WriteAllText(Path, contents);
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="WriteXmlValue" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<XmlFilename ParameterType="System.String" Required="true" />
<XPath ParameterType="System.String" Required="true" />
<Value ParameterType="System.String" Required="true" />
<Namespace ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml" />
<Using Namespace="System.Xml"/>
<Code Type="Fragment" Language="cs">
Log.LogMessage(MessageImportance.Normal, "Updating '" + XPath + "' value(s) in XML file '" + XmlFilename + "'...");
try
{
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.Load(XmlFilename);
XmlNodeList elements = null;
if (!string.IsNullOrEmpty(Namespace))
{
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("ns", Namespace);
elements = doc.SelectNodes(XPath, nsmgr);
}
else
{
elements = doc.SelectNodes(XPath);
}
int count = elements.Count;
if (count > 0)
{
foreach (XmlNode elem in elements)
{
if (elem.GetType() == typeof(XmlElement))
{
((XmlElement)elem).InnerText = Value;
}
else
{
((XmlAttribute)elem).Value = Value;
}
}
doc.Save(XmlFilename);
Log.LogMessage(MessageImportance.Normal, "Updated " + count.ToString() + " values in '" + XmlFilename + "'.");
}
else
{
Log.LogMessage(MessageImportance.Normal, "No XPath match(es) in file '" + XmlFilename + "'.");
}
}
catch (Exception ex)
{
Log.LogErrorFromException(ex, false, false, XmlFilename);
}
</Code>
</Task>
</UsingTask>
</Project>