Skip to content

Commit 184058a

Browse files
authored
Merge branch 'release/8.0.1xx' into darc-release/8.0.1xx-1ceb41d3-7046-4b8f-b713-6bc590a124ab
2 parents efd08c1 + b0f0df8 commit 184058a

File tree

4 files changed

+84
-8
lines changed

4 files changed

+84
-8
lines changed

build/RunTestsOnHelix.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ set PATH=%DOTNET_ROOT%;%PATH%
1010
set DOTNET_MULTILEVEL_LOOKUP=0
1111
set TestFullMSBuild=%1
1212

13+
REM Ensure Visual Studio instances allow preview SDKs
14+
PowerShell -ExecutionPolicy ByPass -NoProfile -File "%HELIX_CORRELATION_PAYLOAD%\t\eng\enable-preview-sdks.ps1"
15+
1316
set TestExecutionDirectory=%CD%\testExecutionDirectory
1417
mkdir %TestExecutionDirectory%
1518

eng/common/tools.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function InstallDotNet([string] $dotnetRoot,
296296
if ($runtime -eq "aspnetcore") { $runtimePath = $runtimePath + "\Microsoft.AspNetCore.App" }
297297
if ($runtime -eq "windowsdesktop") { $runtimePath = $runtimePath + "\Microsoft.WindowsDesktop.App" }
298298
$runtimePath = $runtimePath + "\" + $version
299-
299+
300300
$dotnetVersionLabel = "runtime toolset '$runtime/$architecture v$version'"
301301

302302
if (Test-Path $runtimePath) {
@@ -545,19 +545,25 @@ function LocateVisualStudio([object]$vsRequirements = $null){
545545
})
546546
}
547547

548-
if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
548+
if (!$vsRequirements) {
549+
if (Get-Member -InputObject $GlobalJson.tools -Name 'vs' -ErrorAction SilentlyContinue) {
550+
$vsRequirements = $GlobalJson.tools.vs
551+
} else {
552+
$vsRequirements = $null
553+
}
554+
}
549555
$args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*')
550556

551557
if (!$excludePrereleaseVS) {
552558
$args += '-prerelease'
553559
}
554560

555-
if (Get-Member -InputObject $vsRequirements -Name 'version') {
561+
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'version' -ErrorAction SilentlyContinue)) {
556562
$args += '-version'
557563
$args += $vsRequirements.version
558564
}
559565

560-
if (Get-Member -InputObject $vsRequirements -Name 'components') {
566+
if ($vsRequirements -and (Get-Member -InputObject $vsRequirements -Name 'components' -ErrorAction SilentlyContinue)) {
561567
foreach ($component in $vsRequirements.components) {
562568
$args += '-requires'
563569
$args += $component

eng/enable-preview-sdks.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
param()
2+
3+
. $PSScriptRoot\common\tools.ps1
4+
5+
try {
6+
$vsInfo = LocateVisualStudio
7+
}
8+
catch {
9+
Write-Host "LocateVisualStudio failed: $_"
10+
return
11+
}
12+
13+
if ($null -eq $vsInfo) {
14+
Write-Host "No Visual Studio instance detected; preview SDKs remain enabled by default."
15+
return
16+
}
17+
18+
$vsId = $vsInfo.instanceId
19+
$vsMajorVersion = $vsInfo.installationVersion.Split('.')[0]
20+
$instanceDir = Join-Path $env:USERPROFILE "AppData\Local\Microsoft\VisualStudio\$vsMajorVersion.0_$vsId"
21+
22+
Create-Directory $instanceDir
23+
24+
$sdkFile = Join-Path $instanceDir 'sdk.txt'
25+
26+
$desiredLine = 'UsePreviews=True'
27+
$existingLines = @()
28+
29+
if (Test-Path $sdkFile) {
30+
$existingLines = @(Get-Content -Path $sdkFile -Encoding ASCII)
31+
}
32+
33+
# Determine how to place the UsePreviews flag based on existing content.
34+
$replacementIndex = -1
35+
for ($i = 0; $i -lt $existingLines.Count; $i++) {
36+
if ($existingLines[$i] -match '^UsePreviews=.*$') {
37+
$replacementIndex = $i
38+
break
39+
}
40+
}
41+
42+
# Replace the existing line to enforce it as True
43+
if ($replacementIndex -ge 0) {
44+
$updatedLines = $existingLines
45+
$updatedLines[$replacementIndex] = $desiredLine
46+
}
47+
elseif ($existingLines.Count -gt 0) {
48+
# Write to the top of the file but keep the remaining portion (assumption: order does not matter to VS)
49+
$updatedLines = @($desiredLine) + $existingLines
50+
}
51+
else {
52+
# Write a whole new file
53+
$updatedLines = @($desiredLine)
54+
}
55+
56+
Set-Content -Path $sdkFile -Value $updatedLines -Encoding ASCII
57+
58+
Write-Host "Updated $sdkFile"
59+
Get-Content -Path $sdkFile | ForEach-Object { Write-Host " $_" }

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/DockerRegistryManager.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ public class DockerRegistryManager
2020
public const string FullyQualifiedBaseImageAspNet = $"{BaseImageSource}/{AspNetBaseImage}:{Net8PreviewImageTag}";
2121
private static string? s_registryContainerId;
2222

23+
private static string SDK_AzureContainerRegistryImage => "dotnetdhmirror-f8bzbjakh8cga6ab.azurecr.io/registry:2";
24+
private static string Docker_HubRegistryImage => "docker.io/library/registry:2";
25+
26+
// TODO: some logic to pivot between this and Docker Hub
27+
private static string RegistryImageToUse => SDK_AzureContainerRegistryImage;
28+
29+
2330
public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
2431
{
2532
using TestLoggerFactory loggerFactory = new(testOutput);
2633

27-
if (!new DockerCli(loggerFactory).IsAvailable()) {
34+
if (!new DockerCli(loggerFactory).IsAvailable())
35+
{
2836
throw new InvalidOperationException("Docker is not available, tests cannot run");
2937
}
3038

@@ -40,7 +48,7 @@ public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
4048
{
4149
logger.LogInformation("Spawning local registry at '{registry}', attempt #{attempt}.", LocalRegistry, spawnRegistryAttempt);
4250

43-
CommandResult processResult = ContainerCli.RunCommand(testOutput, "--rm", "--publish", "5010:5000", "--detach", "docker.io/library/registry:2").Execute();
51+
CommandResult processResult = ContainerCli.RunCommand(testOutput, "--rm", "--publish", "5010:5000", "--detach", RegistryImageToUse).Execute();
4452

4553
processResult.Should().Pass().And.HaveStdOut();
4654

@@ -59,7 +67,7 @@ public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
5967
.Execute()
6068
.Should().Pass();
6169

62-
logger.LogInformation("Tagging image '{sourceRepo}/{sourceImage}:{sourceTag}' as '{targetRepo}/{targetImage}:{targetTag}'.",BaseImageSource, RuntimeBaseImage, tag, LocalRegistry, RuntimeBaseImage, tag);
70+
logger.LogInformation("Tagging image '{sourceRepo}/{sourceImage}:{sourceTag}' as '{targetRepo}/{targetImage}:{targetTag}'.", BaseImageSource, RuntimeBaseImage, tag, LocalRegistry, RuntimeBaseImage, tag);
6371
ContainerCli.TagCommand(testOutput, $"{BaseImageSource}/{RuntimeBaseImage}:{tag}", $"{LocalRegistry}/{RuntimeBaseImage}:{tag}")
6472
.Execute()
6573
.Should().Pass();
@@ -84,7 +92,7 @@ public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
8492
{
8593
ContainerCli.StopCommand(testOutput, s_registryContainerId).Execute();
8694
}
87-
catch(Exception ex2)
95+
catch (Exception ex2)
8896
{
8997
logger.LogError(ex2, "Failed to stop the registry {id}.", s_registryContainerId);
9098
}

0 commit comments

Comments
 (0)