forked from DaxStudio/DaxStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.msproj
223 lines (184 loc) · 11 KB
/
build.msproj
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
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="15.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Setup Properties -->
<PropertyGroup>
<SignToolExe>"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\signtool.exe"</SignToolExe>
<MageExe>"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\mage.exe"</MageExe>
<ManifestKeyFile>./lib/DaxStudio.pfx</ManifestKeyFile>
<ManifestThumbPrint>FD452A79B4FA48AD217EE83AE4BF60A5461A5885</ManifestThumbPrint>
<TimeStampUri>http://timestamp.digicert.com</TimeStampUri>
</PropertyGroup>
<ItemGroup>
<VstoProject Include=".\src\DaxStudio.ExcelAddin\DaxStudio.ExcelAddin.csproj" />
</ItemGroup>
<PropertyGroup>
<ReleaseDirectory>.\Release</ReleaseDirectory>
</PropertyGroup>
<Target Name="Clean" DependsOnTargets="MakeReleaseFolder">
<Message Text="Cleaning DaxStudio.Standalone" />
<MSBuild Projects=".\src\daxstudio.sln" Targets="Clean" />
</Target>
<Target Name="DeleteReleaseFolder">
<Message Text="Cleaning Release folder" Importance="High"/>
<RemoveDir Directories="\Release\" />
</Target>
<Target Name="MakeReleaseFolder" DependsOnTargets="DeleteReleaseFolder">
<MakeDir Directories="$(ReleaseDirectory)"/>
</Target>
<Target Name="Build" DependsOnTargets="Clean">
<Message Text="Building DaxStudio.Standalone" />
<MSBuild Projects=".\src\daxstudio.sln" Targets="Build" Properties="RestorePackages=false" />
</Target>
<Target Name="BuildTests" DependsOnTargets="Clean">
<Message Text="Building DaxStudio.Tests" />
<MSBuild Projects=".\tests\daxstudio.Tests\DaxStudio.Tests.csproj" Targets="Build" Properties="RestorePackages=false" />
</Target>
<Target Name="DeletePdb" AfterTargets="Build" DependsOnTargets="Build">
<ItemGroup>
<FilesToDelete Include=".\Release\**\*.pdb"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)" />
</Target>
<Target Name="DeleteXml" AfterTargets="Build" DependsOnTargets="Build">
<ItemGroup>
<FilesToDelete Include=".\Release\**\*.xml"/>
</ItemGroup>
<Delete Files="@(FilesToDelete)" />
</Target>
<PropertyGroup>
<MyAssemblies>.\Release\bin\DaxStudio.dll</MyAssemblies>
</PropertyGroup>
<Target Name="MoveExes" DependsOnTargets="DeleteXml;DeletePdb;SignAssemblies">
<ItemGroup>
<FilesToMove Include=".\Release\bin\DaxStudio.exe;.\Release\bin\DaxStudio.exe.config;.\Release\bin\DaxStudio.Checker.exe;.\Release\bin\DaxStudio.Checker.exe.config;" />
</ItemGroup>
<Message Text="Moving exe files" Importance="High" />
<Move SourceFiles="@(FilesToMove)" DestinationFolder=".\Release" />
</Target>
<Target Name="RetrieveIdentities">
<Message Text="Getting Assembly Versions" Importance="high"/>
<PropertyGroup>
<MyAssemblyInfo/>
</PropertyGroup>
<GetAssemblyIdentity AssemblyFiles="$(MyAssemblies)">
<Output TaskParameter="Assemblies" ItemName="MyAssemblyInfo"/>
</GetAssemblyIdentity>
<PropertyGroup>
<OutVersion>$([System.Version]::Parse(%(MyAssemblyInfo.Version)).ToString(3).Replace('.','_'))</OutVersion>
</PropertyGroup>
<Message Text="Files: %(MyAssemblyInfo.Version)" Importance="high"/>
<Message Text="Major: $(OutVersion) " Importance="high"/>
</Target>
<Target Name="SignAssemblies" DependsOnTargets="Build">
<Message Text="Attempting to sign Assemblies" Importance="high" />
<!-- <Exec Command='$(SignToolExe) sign /sha1 $(ManifestThumbPrint) /t $(TimeStampUri) .\Release\bin\daxstudio.exe' IgnoreExitCode="true"/>
<Exec Command='$(SignToolExe) sign /sha1 $(ManifestThumbPrint) /t $(TimeStampUri) .\Release\bin\daxstudio.checker.exe' IgnoreExitCode="true"/>
<Exec Command='$(SignToolExe) sign /sha1 $(ManifestThumbPrint) /t $(TimeStampUri) .\Release\bin\daxstudio.dll' IgnoreExitCode="true"/> -->
<Exec Command='AzureSignTool sign -kvu "https://daxstudiocert.vault.azure.net/" -kvi "$(KVI_PARAMETER)" -kvs "$(KVS_PARAMETER)" -kvc "$(KVC_PARAMETER)" -kvt "$(KVT_PARAMETER)" -tr "http://rfc3161timestamp.globalsign.com/advanced" -td sha256 -v .\Release\bin\daxstudio.exe'
IgnoreExitCode="false" ContinueOnError="ErrorAndStop" />
<Exec Command='AzureSignTool sign -kvu "https://daxstudiocert.vault.azure.net/" -kvi "$(KVI_PARAMETER)" -kvs "$(KVS_PARAMETER)" -kvc "$(KVC_PARAMETER)" -kvt "$(KVT_PARAMETER)" -tr "http://rfc3161timestamp.globalsign.com/advanced" -td sha256 -v .\Release\bin\daxstudio.checker.exe'
IgnoreExitCode="false" ContinueOnError="ErrorAndStop" />
<Exec Command='AzureSignTool sign -kvu "https://daxstudiocert.vault.azure.net/" -kvi "$(KVI_PARAMETER)" -kvs "$(KVS_PARAMETER)" -kvc "$(KVC_PARAMETER)" -kvt "$(KVT_PARAMETER)" -tr "http://rfc3161timestamp.globalsign.com/advanced" -td sha256 -v .\Release\bin\daxstudio.dll'
IgnoreExitCode="false" ContinueOnError="ErrorAndStop" />
</Target>
<Target Name="SignManifest" DependsOnTargets="SignAssemblies">
<Message Text="Attempting to sign DaxStudio.dll.manifest file" Importance="high"/>
<Exec Command='$(MageExe) -update ".\release\bin\DaxStudio.dll.manifest" -CertHash $(ManifestThumbPrint) -TimeStampUri $(TimeStampUri)' IgnoreExitCode="true"/>
</Target>
<Target Name="SignVsto" DependsOnTargets="SignManifest">
<Message Text="Attempting to sign DaxStudio.vsto file" Importance="high"/>
<Exec WorkingDirectory=".\Release\bin" Command='$(MageExe) -update "DaxStudio.vsto" -CertHash $(ManifestThumbPrint) -appmanifest "DaxStudio.dll.manifest" -TimeStampUri $(TimeStampUri)' />
</Target>
<Target Name="Installer" DependsOnTargets="DeleteXml; DeletePdb;MoveExes">
<Exec Command='"$(MSBuildProgramFiles32)\Inno Setup 6\iscc.exe" .\installer\DaxStudio.iss' />
</Target>
<Target Name="InstallerWithSignedAssemblies" DependsOnTargets="DeleteXml; DeletePdb; SignVsto;MoveExes">
<Exec Command='"$(MSBuildProgramFiles32)\Inno Setup 6\iscc.exe" .\installer\daxstudio.iss' />
</Target>
<Target Name="SignedInstaller" DependsOnTargets="InstallerWithSignedAssemblies; RetrieveIdentities">
<Message Text="Attempting to sign installer" Importance="high" />
<!--<Exec Command='$(SignToolExe) sign /sha1 $(ManifestThumbPrint) /t $(TimeStampUri) .\package\DaxStudio_$(OutVersion)_setup.exe' IgnoreExitCode="true"/>-->
<Exec Command='AzureSignTool sign -kvu "https://daxstudiocert.vault.azure.net/" -kvi "$(KVI_PARAMETER)" -kvs "$(KVS_PARAMETER)" -kvc "$(KVC_PARAMETER)" -kvt "$(KVT_PARAMETER)" -tr "http://rfc3161timestamp.globalsign.com/advanced" -td sha256 -v .\package\DaxStudio_$(OutVersion)_setup.exe'
IgnoreExitCode="false" ContinueOnError="ErrorAndStop" />
<OnError ExecuteTargets="DeleteInstaller" />
</Target>
<Target Name="CreatePortableFile">
<Touch Files=".\Release\bin\.portable" AlwaysCreate="True" />
</Target>
<Target Name="DeleteInstaller" DependsOnTargets="">
<ItemGroup>
<FilesToDelete Include="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion).exe"/>
</ItemGroup>
<Message Text="Deleting installer exe file $(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion).exe" Importance="High"/>
<Delete Files="@(FilesToDelete)" TreatErrorsAsWarnings="True" />
</Target>
<Target Name="DeleteZip" DependsOnTargets="RetrieveIdentities;Build;DeleteXml;DeletePdb">
<ItemGroup>
<FilesToDelete Include="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion).zip"/>
</ItemGroup>
<Message Text="Deleting zip file $(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion).zip" Importance="High"/>
<Delete Files="@(FilesToDelete)" TreatErrorsAsWarnings="True" />
</Target>
<Target Name="Portable" DependsOnTargets="Build;CreatePortableFile;DeleteZip;MoveExes;SignAssemblies">
<ZipDirectory SourceDirectory=".\Release" DestinationFile="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion)_portable.zip" Overwrite="True" />
</Target>
<Target Name="GenerateInstallerHash" DependsOnTargets="SignedInstaller">
<ItemGroup>
<FilesToHash Include="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion)_setup.exe" />
</ItemGroup>
<GenerateHash InputFiles="@(FilesToHash)" OutputFile="$(MSBuildProjectDirectory)\Package\Setup_Hash.txt" />
</Target>
<Target Name="GeneratePortableHash" DependsOnTargets="Portable">
<ItemGroup>
<FilesToHash Include="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion)_portable.zip" />
</ItemGroup>
<GenerateHash InputFiles="@(FilesToHash)" OutputFile="$(MSBuildProjectDirectory)\Package\Portable_Hash.txt" />
</Target>
<Target Name="UnsignedGeneratePortableHash" DependsOnTargets="Portable">
<ItemGroup>
<FilesToHash Include="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion)_portable.zip" />
</ItemGroup>
<GenerateHash InputFiles="@(FilesToHash)" OutputFile="$(MSBuildProjectDirectory)\Package\Portable_Hash.txt" />
</Target>
<Target Name="UnsignedGenerateInstallerHash" DependsOnTargets="SignedInstaller">
<ItemGroup>
<FilesToHash Include="$(MSBuildProjectDirectory)\Package\DaxStudio_$(OutVersion)_setup.exe" />
</ItemGroup>
<GenerateHash InputFiles="@(FilesToHash)" OutputFile="$(MSBuildProjectDirectory)\Package\Setup_Hash.txt" />
</Target>
<Target Name="FullBuild" DependsOnTargets="BuildTests;SignedInstaller;Portable;GeneratePortableHash;GenerateInstallerHash">
<Message Text="Performing full build of Signed Installer and Portable zip" Importance="High" />
</Target>
<Target Name="UnsignedBuild" DependsOnTargets="BuildTests;Installer;Portable;UnsignedGeneratePortableHash; UnsignedGenerateInstallerHash">
<Message Text="Performing full build of Signed Installer and Portable zip" Importance="High" />
</Target>
<UsingTask TaskName="GenerateHash" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<OutputFile ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Security.Cryptography" />
<Code Type="Fragment" Language="cs"><![CDATA[
using (var md5 = SHA256.Create())
{
foreach (var item in InputFiles)
{
string path = item.ItemSpec;
using (FileStream stream = new FileStream(path, FileMode.Open))
{
var fileHash = md5.ComputeHash(stream);
using (TextWriter w = new StreamWriter(OutputFile, false))
{
w.WriteLine(string.Join("", fileHash.Select(b => b.ToString("x2"))));
}
}
}
}
]]></Code>
</Task>
</UsingTask>
</Project>