-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.proj
90 lines (70 loc) · 3.86 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
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="BuildChocolateyPackage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BaseDirectory>$(MSBuildProjectDirectory)</BaseDirectory>
<Configuration Condition="'$(Configuration)'==''" >Release</Configuration>
<Platform Condition="'$(Platform)'==''" >AnyCPU</Platform>
<BuildDirectory>$(BaseDirectory)\.build</BuildDirectory>
<BuildDirectoryFull>$(BuildDirectory)\$(Platform)\$(Configuration)</BuildDirectoryFull>
<PackageDirectory>$(BuildDirectory)\Packages</PackageDirectory>
<SolutionFile>$(BaseDirectory)\HotChocolatey.sln</SolutionFile>
<MSBuildExtensionsPath>C:\Program Files (x86)\MSBuild</MSBuildExtensionsPath>
<MSBuildCommunityTasksPath>$(MSBuildExtensionsPath)\MSBuildCommunityTasks\</MSBuildCommunityTasksPath>
<NuSpecFileName>hot-chocolatey.nuspec</NuSpecFileName>
</PropertyGroup>
<Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets"/>
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
<Target Name="Clean">
<MSBuild Projects="$(SolutionFile)" Targets="Clean" />
<CreateItem Include="$(BuildDirectory)\**\*.*">
<Output TaskParameter="Include" ItemName="FilesToClean" />
</CreateItem>
<Delete Files="@(FilesToClean)" TreatErrorsAsWarnings="true" />
</Target>
<Target Name="Build">
<Message Importance="High" Text="Building $(Configuration)|$(Platform)" />
<MSBuild Projects="$(SolutionFile)" Targets="Build" />
</Target>
<Target Name="BuildChocolateyPackage">
<CallTarget Targets="Clean;UpdateVersion;Build;UpdateNuSpec" />
<Exec Command="choco pack" WorkingDirectory="$(PackageDirectory)" />
</Target>
<Target Name="UpdateVersion">
<PropertyGroup>
<CurrentMonthDay>$([System.DateTime]::Now.ToString(MMdd))</CurrentMonthDay>
<CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
</PropertyGroup>
<AssemblyInfo CodeLanguage="CS"
OutputFile="VersionInfo.cs"
AssemblyCopyright="Copyright (c) Denxorz, $(CurrentYear)"/>
</Target>
<Target Name="UpdateNuSpec">
<CreateItem Include="$(BaseDirectory)\ChocolateyPackage\hot-chocolatey\**\*.*">
<Output TaskParameter="Include" ItemName="NuGetFiles" />
</CreateItem>
<Copy SourceFiles="@(NuGetFiles)"
DestinationFiles="@(NuGetFiles->'$(PackageDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" />
<GetAssemblyIdentity AssemblyFiles="$(BuildDirectoryFull)\HotChocolatey.exe">
<Output TaskParameter="Assemblies" ItemName="AsmInfo" />
</GetAssemblyIdentity>
<Exec Command="checksum -f="$(BuildDirectory)\x86\Release\Setup Hot Chocolatey.msi" -t=sha512" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
<FileUpdate Files="$(PackageDirectory)\tools\chocolateyinstall.ps1;$(PackageDirectory)\tools\chocolateyuninstall.ps1"
Regex="__version__"
ReplacementText="%(AsmInfo.Version)" />
<FileUpdate Files="$(PackageDirectory)\tools\chocolateyinstall.ps1;$(PackageDirectory)\tools\chocolateyuninstall.ps1"
Regex="__checksum__"
ReplacementText="$(OutputOfExec)" />
<XmlUpdate Prefix="nu"
Namespace="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"
XmlFileName="$(PackageDirectory)\$(NuspecFileName)"
XPath="/nu:package/nu:metadata/nu:version"
Value="%(AsmInfo.Version)" />
<XmlUpdate Prefix="nu"
Namespace="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"
XmlFileName="$(PackageDirectory)\$(NuspecFileName)"
XPath="/nu:package/nu:metadata/nu:releaseNotes"
Value="$([System.IO.File]::ReadAllText(CHANGELOG.md))" />
</Target>
</Project>