forked from Code52/pretzel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
111 lines (77 loc) · 4.38 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<Project ToolsVersion="4.0" DefaultTargets="Compile;Test;Chocolatey" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- TODO: mono build -->
<!-- TODO: package step to merge code into one binary -->
<Import Project="$(MSBuildProjectDirectory)\tools\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<Version>$(BUILD_NUMBER)</Version>
<GitCommitHash>$(BUILD_VCS_NUMBER)</GitCommitHash>
<GitCommitHash Condition=" '$(GitCommitHash)' != '' ">$(GitCommitHash.Substring(0, 8))</GitCommitHash>
<!-- dev config -->
<Version Condition=" '$(Version)' == '' ">0.0.0.1</Version>
<ArtifactsDir>$(MSBuildProjectDirectory)\artifacts\</ArtifactsDir>
<TestsDir>$(MSBuildProjectDirectory)\tests\</TestsDir>
<SourceDir>$(MSBuildProjectDirectory)\src\</SourceDir>
<CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
</PropertyGroup>
<UsingTask AssemblyFile=".\tools\xunit\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit" />
<Target Name="Version">
<GitVersion LocalPath="$(SourceDir)\..\" Condition=" '$(GitCommitHash)' == '' ">
<Output TaskParameter="CommitHash" PropertyName="GitCommitHash" />
</GitVersion>
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(SourceDir)\Pretzel\Properties\AssemblyInfo.cs"
AssemblyCopyright="Copyright © Code52 '$(CurrentYear)'"
ComVisible="false"
AssemblyInformationalVersion="Built from hash '$(GitCommitHash)'" />
<Message Text="Building version $(Version) from hash $(GitCommitHash)" Importance="High" />
</Target>
<Target Name="Compile">
<ItemGroup>
<TestsDll Include="$(MSBuildProjectDirectory)\**\bin\$(Configuration)\*.dll" />
<DataDir Include="$(MSBuildProjectDirectory)\**\bin\$(Configuration)\data\*.*" />
</ItemGroup>
<Message Text="=========== Compile ===========" Importance="High" />
<MSBuild Projects="$(SourceDir)\Pretzel.sln" Properties="Configuration=$(Configuration)" Targets="Rebuild" />
<MakeDir Directories="$(ArtifactsDir)" />
<RemoveDir Directories="$(TestsDir)" />
<Copy SourceFiles="$(SourceDir)\Pretzel\bin\$(Configuration)\Pretzel.exe"
DestinationFolder="$(ArtifactsDir)" />
<Copy SourceFiles="@(TestsDll)"
DestinationFolder="$(TestsDir)" />
<Copy SourceFiles="@(DataDir)"
DestinationFolder="$(TestsDir)\data" />
<Message Text="=========== Compile Done ===========" Importance="High" />
<Message Text="Pretzel.exe is available at $(ArtifactsDir)" Importance="High" />
<Message Text="All tests are available at $(TestsDir)" Importance="High" />
</Target>
<Target Name="Test">
<Message Text="=========== Run Tests ===========" Importance="High" />
<ItemGroup>
<TestFiles Include="$(MSBuildProjectDirectory)\**\bin\$(Configuration)\*Tests.dll" />
</ItemGroup>
<xunit Assemblies="@(TestFiles)" />
<Message Text="=========== Tests Passed ===========" Importance="High" />
</Target>
<Target Name="Chocolatey">
<Message Text="=========== Chocolatey Package ===========" Importance="High" />
<ItemGroup>
<NuGet Include="$(MSBuildProjectDirectory)\src\.Nuget\NuGet.exe" />
<OldPackages Include="$(MSBuildProjectDirectory)\artifacts\*.nupkg" />
</ItemGroup>
<PropertyGroup>
<ChocolateyInstall>$(MSBuildProjectDirectory)\build\chocolatey\tools\chocolateyInstall.ps1</ChocolateyInstall>
</PropertyGroup>
<Delete Files="@(OldPackages)" />
<MakeDir Directories="$(MSBuildProjectDirectory)\build\chocolatey\tools" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\tools\chocolatey\pretzel.nuspec"
DestinationFiles="$(MSBuildProjectDirectory)\build\chocolatey\pretzel.nuspec" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\tools\chocolatey\chocolateyInstall.ps1"
DestinationFiles="$(ChocolateyInstall)" />
<FileUpdate Files="$(ChocolateyInstall)"
Regex="{{version}}"
ReplacementText="$(Version)"/>
<Exec Command='"@(NuGet)" pack "$(MSBuildProjectDirectory)\build\chocolatey\pretzel.nuspec" -OutputDirectory "$(MSBuildProjectDirectory)\artifacts" -Version $(Version) -NoPackageAnalysis' />
<Message Text="=========== Package Done ===========" Importance="High" />
</Target>
</Project>