forked from erpnet/ErpNet.FP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.xml
152 lines (126 loc) · 5.55 KB
/
output.xml
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
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="All">
<PropertyGroup>
<OutputPath>Output</OutputPath>
<OutputType>Published</OutputType>
<!-- Increase version when releasing a build -->
<Version>1.1.0.1110</Version>
<WixNamespaces>
<Namespace Prefix="wix" Uri="http://wixtoolset.org/schemas/v4/wxs" />
<Namespace Prefix="ui" Uri="http://wixtoolset.org/schemas/v4/wxs/ui" />
<Namespace Prefix="util" Uri="http://wixtoolset.org/schemas/v4/wxs/util" />
<Namespace Prefix="fg" Uri="http://www.firegiant.com/schemas/v4/wxs/heatwave/buildtools" />
</WixNamespaces>
<MSBuildNamespaces>
<Namespace Prefix="m" Uri="http://schemas.microsoft.com/developer/msbuild/2003" />
</MSBuildNamespaces>
</PropertyGroup>
<UsingTask
TaskName="RegexPoke"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<File ParameterType="System.String" Required="true" />
<Pattern ParameterType="System.String" Required="true" />
<Group ParameterType="System.String" Required="true"/>
<Value ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Code Type="Fragment" Language="cs">
<![CDATA[
var contents = System.IO.File.ReadAllText(File);
var re = new System.Text.RegularExpressions.Regex(Pattern, System.Text.RegularExpressions.RegexOptions.Multiline);
var replaced = re.Replace(contents, match =>
{
var sb = new System.Text.StringBuilder();
var g = match.Groups[Group];
if (g.Success)
{
sb.Append(match.Value, 0, g.Index - match.Index);
sb.Append(Value);
sb.Append(match.Value, g.Index - match.Index + g.Length, match.Length - (g.Index - match.Index + g.Length));
}
else
{
sb.Append(match.Value);
}
return sb.ToString();
});
System.IO.File.WriteAllText(File, replaced);
]]>
</Code>
</Task>
</UsingTask>
<ItemGroup>
<TargetPlatform Include="win-x86" />
<TargetPlatform Include="win-x64" />
<TargetPlatform Include="osx-x64" />
<TargetPlatform Include="linux-x64" />
<TargetPlatform Include="linux-arm" />
</ItemGroup>
<Target Name="PrepareForRelease">
<Message Importance="high" Text="Update version in Product.wxs" />
<XmlPoke
XmlInputPath="$(MSBuildProjectDirectory)\ErpNet.FP.Setup\Product.wxs"
Query="/wix:Wix/wix:Product/@Version"
Namespaces="$(WixNamespaces)"
Value="$(Version)" />
<Message Importance="high" Text="Update versions in Directory.Build.props" />
<XmlPoke
XmlInputPath="$(MSBuildProjectDirectory)\Directory.Build.props"
Query="/Project/PropertyGroup/AssemblyVersion"
Value="$(Version)" />
<XmlPoke
XmlInputPath="$(MSBuildProjectDirectory)\Directory.Build.props"
Query="/Project/PropertyGroup/FileVersion"
Value="$(Version)" />
<XmlPoke
XmlInputPath="$(MSBuildProjectDirectory)\Directory.Build.props"
Query="/Project/PropertyGroup/Version"
Value="$(Version)" />
<Message Importance="high" Text="Calculate hashes" />
<GetFileHash
Files="$(MSBuildProjectDirectory)\ErpNet.FP.Server\wwwroot\app.js">
<Output TaskParameter="Hash" PropertyName="AppJsHash" />
</GetFileHash>
<Message Importance="high" Text="app.js -> $(AppJsHash)" />
<GetFileHash
Files="$(MSBuildProjectDirectory)\ErpNet.FP.Server\wwwroot\index.css">
<Output TaskParameter="Hash" PropertyName="IndexCssHash" />
</GetFileHash>
<Message Importance="high" Text="index.css -> $(IndexCssHash)" />
<Message Importance="high" Text="Updating versions in index.html" />
<RegexPoke
File="$(MSBuildProjectDirectory)\ErpNet.FP.Server\wwwroot\index.html"
Pattern='<script src="app\.js\?ver=(?<ver>.+)"></script>'
Group="ver"
Value="$(AppJsHash)" />
<RegexPoke
File="$(MSBuildProjectDirectory)\ErpNet.FP.Server\wwwroot\index.html"
Pattern='<link rel="stylesheet" href="index\.css\?ver=(?<ver>.+)">'
Group="ver"
Value="$(IndexCssHash)" />
</Target>
<Target Name="PublishToOutputPath">
<Message Text="Performing cleanup..." Importance="high" />
<RemoveDir
Directories="$(OutputPath);$(OutputType)" />
<MakeDir Directories="$(OutputPath);$(OutputType);"/>
<Exec Command="dotnet restore --verbosity q" />
<Message Text="Publishing binaries for %(TargetPlatform.Identity) into $(OutputType) folder..." Importance="high" />
<Exec Command="dotnet publish -r %(TargetPlatform.Identity) -c Release --self-contained=true -p:PublishTrimmed=false -o Published\%(TargetPlatform.Identity) --verbosity q" />
<Message Text="Zipping binaries for all supported target platforms into $(OutputPath) folder..." Importance="high" />
<ZipDirectory
SourceDirectory="$(OutputType)/%(TargetPlatform.Identity)"
DestinationFile="$(OutputPath)/%(TargetPlatform.Identity).zip" />
<Message Text="Everything is ready. Now you could run rebuild of ErpNet.FP.Setup to create the installer into $(OutputPath) folder" Importance="high" />
</Target>
<Target Name="BuildWindowsSetup">
<MSBuild
Projects="$(MSBuildProjectDirectory)\ErpNet.FP.Setup\ErpNet.FP.Setup.wixproj"
Properties="Configuration=Release" />
</Target>
<Target Name="All" DependsOnTargets="PrepareForRelease;PublishToOutputPath;BuildWindowsSetup">
</Target>
</Project>