-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.msbuild
179 lines (144 loc) · 6.63 KB
/
build.msbuild
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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="BuildFull">
<Import Project="Tools\Build\MSBuild.Community.Tasks.Targets"/>
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)packages\xunit.MSBuild.2.0.0.0\tools\xunit.runner.msbuild.dll"
TaskName="Xunit.Runner.MSBuild.xunit" />
<PropertyGroup>
<Major>3</Major>
<Minor>1</Minor>
<Patch>2</Patch>
<PreReleaseString></PreReleaseString>
<VersionInfoString Condition="$(PreReleaseString) != ''">$(Major).$(Minor).$(Patch)-$(PreReleaseString)</VersionInfoString>
<VersionInfoString Condition="$(PreReleaseString) == ''">$(Major).$(Minor).$(Patch)</VersionInfoString>
</PropertyGroup>
<PropertyGroup>
<Configuration>Release</Configuration>
<SourceDir>.\</SourceDir>
<SolutionFilePath>$(SourceDir)MvvmValidation.sln</SolutionFilePath>
<OutputFolderPath>$(SourceDir)Output</OutputFolderPath>
<VersionInfoPath>$(SourceDir)VersionInfo.cs</VersionInfoPath>
<PortableAssemblyOutputFolder>$(OutputFolderPath)\lib\netstandard1.0</PortableAssemblyOutputFolder>
<MainAssemblyWithVersion>$(PortableAssemblyOutputFolder)\MvvmValidation.dll</MainAssemblyWithVersion>
<NuGetPreRelaseVersionSuffix>-beta</NuGetPreRelaseVersionSuffix>
<UnitTestAssembliesPath>$(SourceDir)**\bin\$(Configuration)\*.Tests.dll</UnitTestAssembliesPath>
<UnitTestHtmlReportPath>$(SourceDir)TestReport.html</UnitTestHtmlReportPath>
<ZippedOutputFileName>MvvmValidation.$(VersionInfoString).zip</ZippedOutputFileName>
<ZippedOutputFilePath>$(OutputFolderPath)\$(ZippedOutputFileName)</ZippedOutputFilePath>
<NuGetPath>$(SourceDir)Tools\NuGet.exe</NuGetPath>
</PropertyGroup>
<ItemGroup>
<OutputFolder Include="$(OutputFolderPath)"/>
</ItemGroup>
<PropertyGroup>
<BuildFullDependsOn>
Clean;
BuildSolution;
CleanupAfterBuild;
CopyOutputToAdditionalNuGetFolders;
UnitTest;
ZipOutput;
CreateNuGetPackage
</BuildFullDependsOn>
<BuildSolutionDependsOn>
NuGetRestore;
UpdateVersion
</BuildSolutionDependsOn>
<UpdateVersionDependsOn>
</UpdateVersionDependsOn>
<CreateNuGetPackageDependsOn>
BuildSolution
</CreateNuGetPackageDependsOn>
<CleanupAfterBuildDependsOn>
BuildSolution
</CleanupAfterBuildDependsOn>
<UnitTestDependsOn>
BuildSolution
</UnitTestDependsOn>
<ZipOutputDependsOn>
BuildSolution
</ZipOutputDependsOn>
</PropertyGroup>
<Target Name="BuildFull"
DependsOnTargets="$(BuildFullDependsOn)">
</Target>
<Target Name="Clean">
<MSBuild Projects="$(SolutionFilePath)"
ContinueOnError="false"
Properties="Configuration=$(Configuration)"
Targets="Clean" />
<CreateItem Include="%(OutputFolder.FullPath)\**\*.*">
<Output TaskParameter="Include"
ItemName="FilesToRemove"/>
</CreateItem>
<Delete Files="%(FilesToRemove.FullPath)"
ContinueOnError="true" />
<RemoveDir Directories="%(OutputFolder.FullPath)"
ContinueOnError="true"/>
<MakeDir Directories="%(OutputFolder.FullPath)"
ContinueOnError="true"/>
</Target>
<Target Name="BuildSolution"
DependsOnTargets="$(BuildSolutionDependsOn)">
<MSBuild Projects="$(SolutionFilePath)"
ContinueOnError="false"
Properties="Configuration=$(Configuration);BuildInParallel=True">
<Output ItemName="BuildOutput"
TaskParameter="TargetOutputs"/>
</MSBuild>
</Target>
<Target Name="CopyOutputToAdditionalNuGetFolders">
</Target>
<Target Name="CleanupAfterBuild"
DependsOnTargets="$(CleanupAfterBuildDependsOn)">
<!-- Delete code analysis files -->
<CreateItem Include="$(OutputFolderPath)\**\*CodeAnalysisLog.xml">
<Output TaskParameter="Include"
ItemName="CodeAnalysisFiles" />
</CreateItem>
<CreateItem Include="$(OutputFolderPath)\**\*.lastcodeanalysissucceeded">
<Output TaskParameter="Include"
ItemName="CodeAnalysisFiles" />
</CreateItem>
<Delete Files="%(CodeAnalysisFiles.FullPath)"
ContinueOnError="false" />
</Target>
<Target Name="UnitTest"
DependsOnTargets="$(UnitTestDependsOn)">
<CreateItem Include="$(UnitTestAssembliesPath)">
<Output TaskParameter="Include"
ItemName="UnitTestAssemblies" />
</CreateItem>
<Message Text="@(UnitTestAssemblies)"/>
<xunit Assemblies="@(UnitTestAssemblies)"
Html="$(UnitTestHtmlReportPath)" />
</Target>
<Target Name="UpdateVersion"
DependsOnTargets="$(UpdateVersionDependsOn)">
<Message Text="Version: $(VersionInfoString)"/>
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(VersionInfoPath)"
AssemblyVersion="$(Major).$(Minor).$(Patch)"
AssemblyFileVersion="$(Major).$(Minor).$(Patch)"
AssemblyInformationalVersion="$(VersionInfoString)"/>
<XmlUpdate XmlFileName="Package.nuspec"
XPath="package/metadata/version"
Value="$(VersionInfoString)"/>
</Target>
<Target Name="CreateNuGetPackage"
DependsOnTargets="$(CreateNuGetPackageDependsOn)">
<Exec Command="Tools\NuGet.exe pack Package.nuspec -BasePath $(OutputFolderPath) -OutputDirectory $(OutputFolderPath) -Exclude **\Tests\** -Exclude **\*.pdb -Exclude **\$(ZippedOutputFileName)"/>
</Target>
<Target Name="ZipOutput"
DependsOnTargets="$(ZipOutputDependsOn)">
<ItemGroup>
<ZipOutputFiles Include="$(OutputFolderPath)\lib\**\*.*" />
</ItemGroup>
<Zip Files="@(ZipOutputFiles)"
WorkingDirectory="$(OutputFolderPath)"
ZipFileName="$(ZippedOutputFilePath)" />
</Target>
<Target Name="NuGetRestore">
<Message Text="Restoring NuGet Packages..."/>
<Exec Command="$(NuGetPath) Restore $(SolutionFilePath)"/>
</Target>
</Project>