Skip to content

Commit ee0c438

Browse files
authored
Make SmokeTests use repo infrastructure (#19290)
1 parent 82cad63 commit ee0c438

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+770
-419
lines changed

src/SourceBuild/content/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@
33
/artifacts
44
/prereqs/packages
55
/src/nuget-client/NuGet.config
6-
/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin
7-
/test/Microsoft.DotNet.SourceBuild.SmokeTests/obj
8-
/test/Microsoft.DotNet.SourceBuild.SmokeTests/TestResults
96
*.binlog

src/SourceBuild/content/Directory.Build.props

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@
7373
<TargetRid Condition="'$(ShortStack)' == 'true' and '$(TargetOS)' == 'windows'">win-$(TargetArchitecture)</TargetRid>
7474
</PropertyGroup>
7575

76+
<!-- Set NuGetPackageRoot before Arcade SDK sets it. -->
77+
<PropertyGroup>
78+
<!-- Set RestorePackagesPath so that we don't accidentally pull some packages from the global location. -->
79+
<RestorePackagesPath Condition="'$(RestorePackagesPath)' == ''">$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '.packages'))</RestorePackagesPath>
80+
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == ''">$(RestorePackagesPath)</NuGetPackageRoot>
81+
</PropertyGroup>
82+
7683
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(SkipArcadeSdkImport)' != 'true'" />
7784

7885
<!-- Init basic Arcade props, if the project importing this file doesn't use Arcade.
7986
Keep in sync with props/targets in the Arcade.Sdk. -->
8087
<PropertyGroup Condition="'$(SkipArcadeSdkImport)' == 'true'">
81-
<!-- RepoLayout.props -->
82-
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' != ''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)'))</NuGetPackageRoot>
83-
<NuGetPackageRoot Condition="'$(NuGetPackageRoot)' == '' and '$(NUGET_PACKAGES)' != ''">$([MSBuild]::NormalizeDirectory('$(NUGET_PACKAGES)'))</NuGetPackageRoot>
84-
8588
<RepoRoot Condition="'$(RepoRoot)' == ''">$([MSBuild]::NormalizeDirectory('$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'global.json'))'))</RepoRoot>
8689

8790
<!-- Respect environment variable for the .NET install directory if set; otherwise, use the repo default location -->
@@ -212,6 +215,7 @@
212215
<PoisonMarkerFile>.prebuilt.xml</PoisonMarkerFile>
213216
<PoisonReportDataFile>$(PackageReportDir)poison-catalog.xml</PoisonReportDataFile>
214217
<PoisonedReportFile>$(PackageReportDir)poisoned.txt</PoisonedReportFile>
218+
<PoisonUsageReportFile>$(PackageReportDir)poison-usage.xml</PoisonUsageReportFile>
215219
</PropertyGroup>
216220

217221
</Project>

src/SourceBuild/content/Directory.Build.targets

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@
66
<PropertyGroup>
77
<SdkFilenamePrefix>dotnet-sdk-</SdkFilenamePrefix>
88
</PropertyGroup>
9+
910
<ItemGroup>
1011
<SdkTarballItem Include="$(ArtifactsAssetsDir)Sdk/**/$(SdkFilenamePrefix)*$(ArchiveExtension)" />
1112
</ItemGroup>
1213

1314
<!--
1415
Extract SDK version from SDK tarball filename.
16+
Keep in sync with dotnet-sdk's archive location and filename.
1517
1618
Example:
17-
dotnet-sdk-9.0.100-alpha.1.24057.1-fedora.38-x64.tar.gz
18-
dotnet-sdk-<SdkVersion>-<TargetRid><ArchiveExtension>
19+
artifacts\assets\<config>\Sdk\9.0.100-alpha.1.24057.1\dotnet-sdk-9.0.100-alpha.1.24057.1-fedora.38-x64.tar.gz
20+
artifacts\assets\<config>\Sdk\<SdkVersion>\dotnet-sdk-<SdkVersion>-<TargetRid><ArchiveExtension>
1921
-->
2022
<PropertyGroup>
2123
<SdkFilename>%(SdkTarballItem.Filename)%(SdkTarballItem.Extension)</SdkFilename>
22-
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
24+
<SdkTarballPath Condition="'$(SdkTarballPath)' == ''">%(SdkTarballItem.Identity)</SdkTarballPath>
2325
<SourceBuiltSdkVersion>$(SdkFilename.Replace('$(SdkFilenamePrefix)','').Replace('-$(TargetRid)$(ArchiveExtension)',''))</SourceBuiltSdkVersion>
2426
</PropertyGroup>
2527
</Target>
2628

27-
</Project>
29+
</Project>

src/SourceBuild/content/Directory.Packages.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingVersion)" />
1717
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsoleVersion)" />
1818
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
19+
<!-- External dependencies -->
20+
<PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
21+
<PackageVersion Include="xunit.extensibility.core" Version="$(XUnitVersion)" />
22+
<PackageVersion Include="xunit.extensibility.execution" Version="$(XUnitVersion)" />
1923
</ItemGroup>
2024

2125
</Project>

src/SourceBuild/content/build.proj

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
1-
<Project>
2-
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
1+
<Project Sdk="Microsoft.Build.Traversal">
32

4-
<PropertyGroup>
5-
<!-- Fake, to satisfy the SDK. -->
6-
<TargetFramework>netstandard2.0</TargetFramework>
7-
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
8-
</PropertyGroup>
3+
<ItemGroup>
4+
<ProjectReference Include="$(ToolsDir)init-build.proj" BuildInParallel="false" />
5+
<ProjectReference Include="$(RepoProjectsDir)$(RootRepo).proj" BuildInParallel="false" />
6+
</ItemGroup>
97

10-
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
11-
12-
<Target Name="Build">
8+
<Target Name="PrintInfo" BeforeTargets="Build">
139
<PropertyGroup>
1410
<BuildModeInfoText Condition="'$(DotNetBuildSourceOnly)' == 'true'">source-build</BuildModeInfoText>
1511
<BuildModeInfoText Condition="'$(DotNetBuildSourceOnly)' != 'true'">non-source-build</BuildModeInfoText>
1612
</PropertyGroup>
1713

1814
<Message Text="Build Mode: $(BuildModeInfoText)" Importance="high" />
1915
<Message Text="Build Environment: $(TargetArchitecture) $(Configuration) $(TargetOS) $(TargetRid)" Importance="high" />
20-
21-
<MSBuild Projects="$(ToolsDir)init-build.proj;
22-
$(RepoProjectsDir)$(RootRepo).proj"
23-
Targets="Build"
24-
BuildInParallel="false"
25-
StopOnFirstFailure="true" />
2616
</Target>
2717

2818
<!-- Create a merge manifest from the individual repository manifest files. -->
29-
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.MergeAssetManifests" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" />
19+
<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.MergeAssetManifests" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
3020
<Target Name="MergeAssetManifests" AfterTargets="Build">
31-
<PropertyGroup>
21+
<PropertyGroup>
3222
<MergedAssetManifestOutputPath>$(ArtifactsDir)VerticalManifest.xml</MergedAssetManifestOutputPath>
3323
</PropertyGroup>
3424

@@ -48,8 +38,8 @@
4838
<!-- Intentionally below the import to appear at the end. -->
4939
<Target Name="LogBuildOutputFolders"
5040
AfterTargets="Build">
51-
<Message Importance="high" Text="Shipping packages are located in '$(ArtifactsShippingPackagesDir)'." />
52-
<Message Importance="high" Text="Shipping assets are located in '$(ArtifactsAssetsDir)'." />
41+
<Message Importance="high" Text="Shipping packages are located in '$(ArtifactsShippingPackagesDir)'." />
42+
<Message Importance="high" Text="Shipping assets are located in '$(ArtifactsAssetsDir)'." />
5343
</Target>
5444

5545
</Project>

src/SourceBuild/content/build.sh

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ usage()
1818
echo "Actions:"
1919
echo " --clean Clean the solution"
2020
echo " --help Print help and exit (short: -h)"
21-
echo " --test Run smoke tests (short: -t)"
21+
echo " --test Run tests (short: -t)"
2222
echo ""
2323

2424
echo "Source-only settings:"
@@ -33,7 +33,7 @@ usage()
3333
echo ""
3434

3535
echo "Advanced settings:"
36-
echo " --build-tests Build repository tests. May not be supported with --source-only"
36+
echo " --build-repo-tests Build repository tests. May not be supported with --source-only"
3737
echo " --ci Set when running on CI server"
3838
echo " --clean-while-building Cleans each repo after building (reduces disk space usage, short: -cwb)"
3939
echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
@@ -56,10 +56,7 @@ while [[ -h "$source" ]]; do
5656
done
5757
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
5858

59-
# Set the NUGET_PACKAGES dir so that we don't accidentally pull some packages from the global location,
60-
# They should be pulled from the local feeds.
6159
packagesRestoredDir="$scriptroot/.packages/"
62-
export NUGET_PACKAGES=$packagesRestoredDir/
6360

6461
# Common settings
6562
binary_log=false
@@ -112,8 +109,6 @@ while [[ $# > 0 ]]; do
112109
exit 0
113110
;;
114111
-test|-t)
115-
export NUGET_PACKAGES=$NUGET_PACKAGES/smoke-tests
116-
properties="$properties /t:RunSmokeTest"
117112
test=true
118113
;;
119114

@@ -180,7 +175,6 @@ while [[ $# > 0 ]]; do
180175
-use-mono-runtime)
181176
properties="$properties /p:SourceBuildUseMonoRuntime=true"
182177
;;
183-
184178
*)
185179
properties="$properties $1"
186180
;;
@@ -195,19 +189,37 @@ if [[ "$ci" == true ]]; then
195189
fi
196190
fi
197191

192+
# Never use the global nuget cache folder
193+
use_global_nuget_cache=false
194+
198195
. "$scriptroot/eng/common/tools.sh"
199196

197+
project="$scriptroot/build.proj"
198+
targets="/t:Build"
199+
200+
# This repo uses the VSTest integration instead of the Arcade Test target
201+
if [[ "$test" == true ]]; then
202+
project="$scriptroot/test/tests.proj"
203+
targets="$targets;VSTest"
204+
fi
205+
200206
function Build {
201207
if [[ "$sourceOnly" != "true" ]]; then
202208

203209
InitializeToolset
204210

211+
# Manually unset NUGET_PACKAGES as InitializeToolset sets it unconditionally.
212+
# The env var shouldn't be set so that the RestorePackagesPath msbuild property is respected.
213+
unset NUGET_PACKAGES
214+
205215
local bl=""
206216
if [[ "$binary_log" == true ]]; then
207217
bl="/bl:\"$log_dir/Build.binlog\""
208218
fi
209219

210-
MSBuild "$scriptroot/build.proj" \
220+
MSBuild --restore \
221+
$project \
222+
$targets \
211223
$bl \
212224
/p:Configuration=$configuration \
213225
$properties
@@ -220,22 +232,22 @@ function Build {
220232
properties="$properties /p:ContinuousIntegrationBuild=true"
221233
fi
222234

223-
"$CLI_ROOT/dotnet" build-server shutdown
224-
225-
if [ "$test" == "true" ]; then
226-
"$CLI_ROOT/dotnet" msbuild "$scriptroot/build.proj" -bl:"$scriptroot/artifacts/log/$configuration/BuildTests.binlog" -flp:"LogFile=$scriptroot/artifacts/log/$configuration/BuildTests.log" -clp:v=m $properties
227-
else
235+
if [ "$test" != "true" ]; then
236+
"$CLI_ROOT/dotnet" build-server shutdown
228237
"$CLI_ROOT/dotnet" msbuild "$scriptroot/eng/tools/init-build.proj" -bl:"$scriptroot/artifacts/log/$configuration/BuildMSBuildSdkResolver.binlog" -flp:LogFile="$scriptroot/artifacts/log/$configuration/BuildMSBuildSdkResolver.log" /t:ExtractToolsetPackages,BuildMSBuildSdkResolver $properties
229-
230238
# kill off the MSBuild server so that on future invocations we pick up our custom SDK Resolver
231239
"$CLI_ROOT/dotnet" build-server shutdown
240+
fi
232241

233-
# Point MSBuild to the custom SDK resolvers folder, so it will pick up our custom SDK Resolver
234-
export MSBUILDADDITIONALSDKRESOLVERSFOLDER="$scriptroot/artifacts/toolset/VSSdkResolvers/"
242+
# Point MSBuild to the custom SDK resolvers folder, so it will pick up our custom SDK Resolver
243+
export MSBUILDADDITIONALSDKRESOLVERSFOLDER="$scriptroot/artifacts/toolset/VSSdkResolvers/"
235244

236-
"$CLI_ROOT/dotnet" msbuild "$scriptroot/build.proj" -bl:"$scriptroot/artifacts/log/$configuration/Build.binlog" -flp:"LogFile=$scriptroot/artifacts/log/$configuration/Build.log" $properties
245+
local bl=""
246+
if [[ "$binary_log" == true ]]; then
247+
bl="/bl:\"$log_dir/Build.binlog\""
237248
fi
238249

250+
"$CLI_ROOT/dotnet" msbuild --restore "$project" $bl $targets $properties
239251
fi
240252
}
241253

src/SourceBuild/content/eng/Versions.props

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
-->
2626
<PrivateSourceBuiltSdkVersion>9.0.100-preview.4.24179.1</PrivateSourceBuiltSdkVersion>
2727
<PrivateSourceBuiltArtifactsVersion>9.0.100-preview.4.24179.1</PrivateSourceBuiltArtifactsVersion>
28-
<!-- msbuild -->
29-
<MicrosoftBuildVersion>17.8.3</MicrosoftBuildVersion>
30-
<!-- runtime -->
31-
<MicrosoftExtensionsFileSystemGlobbingVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsFileSystemGlobbingVersion>
32-
<MicrosoftExtensionsLoggingConsoleVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsLoggingConsoleVersion>
33-
<MicrosoftExtensionsLoggingVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsLoggingVersion>
34-
<!-- command-line-api -->
28+
<!-- command-line-api dependencies -->
3529
<SystemCommandLineVersion>2.0.0-beta4.24126.1</SystemCommandLineVersion>
30+
<!-- msbuild dependencies -->
31+
<MicrosoftBuildVersion>17.8.3</MicrosoftBuildVersion>
32+
<!-- runtime dependencies -->
33+
<MicrosoftExtensionsFileSystemGlobbingVersion>8.0.0</MicrosoftExtensionsFileSystemGlobbingVersion>
34+
<MicrosoftExtensionsLoggingConsoleVersion>8.0.0</MicrosoftExtensionsLoggingConsoleVersion>
35+
<MicrosoftExtensionsLoggingVersion>8.0.0</MicrosoftExtensionsLoggingVersion>
36+
<!-- external dependencies -->
37+
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
3638
</PropertyGroup>
3739
</Project>

src/SourceBuild/content/eng/build.ps1

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Param(
88
# Actions
99
[switch]$clean,
1010
[switch][Alias('h')]$help,
11+
[switch][Alias('t')]$test,
1112

1213
# Advanced settings
13-
[switch]$buildTests,
14+
[switch]$buildRepoTests,
1415
[switch]$ci,
1516
[switch][Alias('cwb')]$cleanWhileBuilding,
1617
[switch][Alias('nobl')]$excludeCIBinarylog,
@@ -28,42 +29,61 @@ function Get-Usage() {
2829
Write-Host "Actions:"
2930
Write-Host " -clean Clean the solution"
3031
Write-Host " -help Print help and exit (short: -h)"
32+
Write-Host " -test Run tests (repo tests omitted by default) (short: -t)"
3133
Write-Host ""
3234

3335
Write-Host "Advanced settings:"
34-
Write-Host " -build-tests Build repository tests"
36+
Write-Host " -buildRepoTests Build repository tests"
3537
Write-Host " -ci Set when running on CI server"
3638
Write-Host " -cleanWhileBuilding Cleans each repo after building (reduces disk space usage, short: -cwb)"
3739
Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl)"
3840
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
3941
Write-Host ""
4042
}
4143

42-
. $PSScriptRoot\common\tools.ps1
44+
$useGlobalNuGetCache=$false
4345

44-
# Set the NUGET_PACKAGES dir so that we don't accidentally pull some packages from the global location,
45-
# They should be pulled from the local feeds.
46-
$env:NUGET_PACKAGES="$RepoRoot\.packages\"
46+
. $PSScriptRoot\common\tools.ps1
4747

4848
if ($help) {
4949
Get-Usage
5050
exit 0
5151
}
5252

53+
$project = Join-Path $RepoRoot "build.proj"
54+
$arguments = @()
55+
$targets = "/t:Build"
56+
57+
# This repo uses the VSTest integration instead of the Arcade Test target
58+
if ($test) {
59+
$project = Join-Path (Join-Path $RepoRoot "test") "tests.proj"
60+
$targets += ";VSTest"
61+
}
62+
63+
if ($buildRepoTests) {
64+
$arguments += "/p:DotNetBuildTests=true"
65+
}
66+
67+
if ($cleanWhileBuilding) {
68+
$arguments += "/p:CleanWhileBuilding=true"
69+
}
70+
5371
function Build {
5472
InitializeToolset
5573

74+
# Manually unset NUGET_PACKAGES as InitializeToolset sets it unconditionally.
75+
# The env var shouldn't be set so that the RestorePackagesPath msbuild property is respected.
76+
$env:NUGET_PACKAGES=''
77+
5678
$bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'Build.binlog') } else { '' }
57-
$cwb = if ($cleanWhileBuilding) { '/p:CleanWhileBuilding=true' } else { '' }
58-
$btst = if ($buildTests) { '/p:DotNetBuildTests=true' } else { '' }
59-
$buildProj = Join-Path $RepoRoot 'build.proj'
6079

61-
MSBuild $buildProj `
80+
MSBuild -restore `
81+
$project `
6282
$bl `
83+
$targets `
6384
/p:Configuration=$configuration `
64-
$cwb `
65-
$btst `
66-
@properties
85+
@properties `
86+
@arguments
6787
}
6888

6989
try {

0 commit comments

Comments
 (0)