-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.proj
178 lines (146 loc) · 10.1 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
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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="17.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageVersion Condition=" '$(PackageVersion)' == '' ">1.0.41</PackageVersion>
<Build_Number Condition=" '$(Build_Number)' == '' ">0</Build_Number>
<Version>$(PackageVersion).$(Build_Number)</Version>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<BinPath>$(MSBuildThisFileDirectory)bin\$(Configuration)</BinPath>
<OutPath>$(BinPath)\out</OutPath>
<PackagePath>$(BinPath)\package</PackagePath>
<PackageCachePath>$(BinPath)\cache</PackageCachePath>
<IntegrationTestResults>$(BinPath)\IntegrationTestResults.txt</IntegrationTestResults>
</PropertyGroup>
<Target Name="Test" DependsOnTargets="IntegrationTest">
<Exec Command='dotnet restore $(MSBuildThisFileDirectory)TeamCity.VSTest.TestLogger.Tests\TeamCity.VSTest.TestLogger.Tests.csproj'/>
<Exec Command='dotnet test $(MSBuildThisFileDirectory)TeamCity.VSTest.TestLogger.Tests\TeamCity.VSTest.TestLogger.Tests.csproj -c $(Configuration)'/>
</Target>
<Target Name="Pack" DependsOnTargets="Build">
<MSBuild Projects="$(MSBuildThisFileDirectory)TeamCity.VSTest.TestLogger\TeamCity.VSTest.TestLogger.csproj" Targets="Pack" Properties="Configuration=$(Configuration);PackageVersion=$(PackageVersion);PublishDir=$(PackagePath)"/>
<ItemGroup>
<PackageFiles Include="$(MSBuildThisFileDirectory)TeamCity.VSTest.TestLogger\bin\$(configuration)\*.nupkg"/>
</ItemGroup>
<Copy SourceFiles="@(PackageFiles)" DestinationFolder="$(PackagePath)"/>
<Message Text="##teamcity[publishArtifacts '$(PackagePath)\TeamCity.VSTest.TestAdapter.*.nupkg=>.']" />
</Target>
<Target Name="Build">
<MSBuild Projects="TeamCity.VSTest.TestAdapter.sln" Targets="Restore"/>
<ItemGroup>
<VSTestVersion Include="vstest15.3">
<TargetFramework>netstandard1.5</TargetFramework>
<VSTestLoggerPath>vstest15</VSTestLoggerPath>
<AssemblyName>TeamCity.VSTest.TestLogger</AssemblyName>
</VSTestVersion>
<VSTestVersion Include="vstest15">
<TargetFramework>netstandard1.5</TargetFramework>
<VSTestLoggerPath>vstest15</VSTestLoggerPath>
<AssemblyName>TeamCity.VSTest.TestAdapter</AssemblyName>
</VSTestVersion>
<VSTestVersion Include="vstest14">
<TargetFramework>net40</TargetFramework>
<VSTestLoggerPath>vstest14</VSTestLoggerPath>
<AssemblyName>TeamCity.VSTest.TestAdapter</AssemblyName>
</VSTestVersion>
<VSTestVersion Include="vstest12">
<TargetFramework>net35</TargetFramework>
<VSTestLoggerPath>vstest12</VSTestLoggerPath>
<AssemblyName>TeamCity.VSTest.TestAdapter</AssemblyName>
</VSTestVersion>
</ItemGroup>
<RemoveDir Directories="$(BinPath)" ContinueOnError="True" />
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Publish" Properties="Configuration=$(Configuration);TargetFramework=%(VSTestVersion.TargetFramework);VSTestLoggerPath=%(VSTestVersion.VSTestLoggerPath);Version=$(Version);AssemblyName=%(VSTestVersion.AssemblyName)"/>
<Message Text="##teamcity[publishArtifacts '$(OutPath)\**\*.dll=>TeamCity.VSTest.TestLogger.zip']" />
</Target>
<Target Name="ClearNugetCache">
<Exec Command="dotnet nuget locals global-packages --list" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" ItemName="GlobaPackagesInfo" />
</Exec>
<PropertyGroup>
<CachePath>@(GlobaPackagesInfo->Replace("info : global-packages:", "")->Trim())</CachePath>
</PropertyGroup>
<Message Text='CachePath=$(CachePath)' />
<RemoveDir Directories="$(CachePath)teamcity.vstest.testadapter\$(PackageVersion)" ContinueOnError="True" />
</Target>
<Target Name="Publish">
<PropertyGroup>
<PublishPath>$(BinPath)\$(VSTestLoggerPath)</PublishPath>
<OutPath>$(OutPath)\$(VSTestLoggerPath)</OutPath>
</PropertyGroup>
<MSBuild
Projects="$(MSBuildThisFileDirectory)TeamCity.VSTest.TestLogger\TeamCity.VSTest.TestLogger.csproj"
Targets="Publish"
Properties="Configuration=$(Configuration);Version=$(Version);TargetFramework=$(TargetFramework);PublishDir=$(PublishPath)"/>
<ItemGroup>
<AdapterFiles Include="$(PublishPath)\TeamCity.*.dll"/>
<AdapterFiles Include="$(PublishPath)\IoC*.dll"/>
</ItemGroup>
<Move SourceFiles="@(AdapterFiles)" DestinationFolder="$(OutPath)"/>
<RemoveDir Directories="$(PublishPath)" ContinueOnError="True" />
</Target>
<Target Name="IntegrationTest" DependsOnTargets="Pack;ClearNugetCache">
<Message Text='"$(MSBuildToolsPath)\msbuild.exe" "$(MSBuildThisFileFullPath)" /t:DispatchIntegrationTest /p:Configuration=$(Configuration) > "$(IntegrationTestResults)"' />
<Message Text='WorkingDirectory="$(MSBuildThisFileDirectory)"' />
<Exec Command='"$(MSBuildToolsPath)\msbuild.exe" "$(MSBuildThisFileFullPath)" /t:DispatchIntegrationTest /p:Configuration=$(Configuration) > "$(IntegrationTestResults)"' WorkingDirectory="$(MSBuildThisFileDirectory)"/>
</Target>
<Target Name="DispatchIntegrationTest">
<ItemGroup>
<DotnetTool Include='$(ProgramW6432)\dotnet\sdk\**\dotnet.dll'/>
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DotnetIntegrationTest" Properties='Configuration=$(Configuration);DotnetPath=%(DotnetTool.Identity);TestProjectName=MS.Tests;DotnetMessagesCount=34;MSBuildMessagesCount=15'/>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DotnetIntegrationTest" Properties='Configuration=$(Configuration);DotnetPath=%(DotnetTool.Identity);TestProjectName=XUnit.Tests;DotnetMessagesCount=24;MSBuildMessagesCount=10'/>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DotnetIntegrationTest" Properties='Configuration=$(Configuration);DotnetPath=%(DotnetTool.Identity);TestProjectName=Dual.Tests;DotnetMessagesCount=24;MSBuildMessagesCount=12'/>
</Target>
<Target Name="DotnetIntegrationTest">
<PropertyGroup>
<DotnetDir>$([System.IO.Path]::GetDirectoryName("$(DotnetPath)"))</DotnetDir>
<DotnetVersion>$([System.IO.Path]::GetFileName("$(DotnetDir)"))</DotnetVersion>
<DotnetVersionName>$(DotnetVersion)</DotnetVersionName>
<DotnetVersionName Condition=" '$(DotnetVersionName)' == '' ">Default</DotnetVersionName>
<TestProject>IntegrationTests\$(TestProjectName)\$(TestProjectName).csproj</TestProject>
<TestAssembly>IntegrationTests\$(TestProjectName)\bin\$(Configuration)\net452\$(TestProjectName).dll</TestAssembly>
<CleanCommand>dotnet clean "$(TestProject)" -c $(Configuration)</CleanCommand>
<RestoreCommand>dotnet restore "$(TestProject)" --packages "$(PackageCachePath)" --no-cache "/p:RestoreAdditionalProjectSources=$(PackagePath)"</RestoreCommand>
<BuildCommand>dotnet build "$(TestProject)" -c $(Configuration) "/p:RestoreAdditionalProjectSources=$(PackagePath)"</BuildCommand>
<TestCommand>dotnet test "$(TestProject)" -c $(Configuration) --no-build --verbosity normal</TestCommand>
<MSBuildTestCommand>"C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "$(TestAssembly)" /Logger:logger://teamcity /TestAdapterPath:. /Framework:Framework45</MSBuildTestCommand>
</PropertyGroup>
<Message Text="Create global.json" />
<ItemGroup>
<GlobalJsonFile Include="IntegrationTests\global.json"/>
<GlobalJsonFileLine Include='{'/>
<GlobalJsonFileLine Include=' "sdk": {'/>
<GlobalJsonFileLine Include=' "version": "$(DotnetVersionName)"'/>
<GlobalJsonFileLine Include=' }'/>
<GlobalJsonFileLine Include='}'/>
</ItemGroup>
<WriteLinesToFile
File="@(GlobalJsonFile)"
Lines="@(GlobalJsonFileLine)"
Overwrite="true"
Encoding="UTF-8"/>
<Message Text="!!!Start" />
<Message Text="Dotnet: $(DotnetVersionName), TestProject: $(TestProjectName)" />
<Message Text="!!!Commands" />
<Message Text="$(CleanCommand)" />
<Message Text="$(RestoreCommand)" />
<Message Text="$(BuildCommand)" />
<Message Text="$(TestCommand)" />
<Message Text="$(MSBuildTestCommand)" Condition=" '$(DotnetVersion)' == '' "/>
<Message Text="!!!Results" />
<Exec Command='$(CleanCommand)'><Output TaskParameter="ExitCode" PropertyName="ErrorCode"/></Exec>
<Message Importance="high" Text="Exit code of $(CleanCommand): $(ErrorCode)"/>
<Exec Command='$(RestoreCommand)'><Output TaskParameter="ExitCode" PropertyName="ErrorCode"/></Exec>
<Message Importance="high" Text="Exit code of $(RestoreCommand): $(ErrorCode)"/>
<Exec Command='$(BuildCommand)'><Output TaskParameter="ExitCode" PropertyName="ErrorCode"/></Exec>
<Message Importance="high" Text="Exit code of $(BuildCommand): $(ErrorCode)"/>
<Message Text="!!!Messages:$(DotnetMessagesCount)" />
<Exec IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" Command='$(TestCommand)'><Output TaskParameter="ExitCode" PropertyName="ErrorCode"/></Exec>
<Message Importance="high" Text="Exit code of $(TestCommand): $(ErrorCode)"/>
<Message Text="!!!Messages:$(MSBuildMessagesCount)" Condition=" '$(DotnetVersion)' == '' "/>
<Exec IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" Condition=" '$(DotnetVersion)' == '' " Command='$(MSBuildTestCommand)'><Output TaskParameter="ExitCode" PropertyName="ErrorCode"/></Exec>
<Message Importance="high" Text="Exit code of $(MSBuildTestCommand): $(ErrorCode)"/>
<Message Text="!!!Finish" />
</Target>
</Project>