Skip to content

Commit 6319e34

Browse files
authored
[release/dev18.0] Fix build task integration tests (#81245)
Backport of #81128. Closes #81246.
1 parent 1b81707 commit 6319e34

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

eng/build-utils.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,21 @@ function Unsubst-TempDir() {
268268
$env:TMP=$originalTemp
269269
}
270270
}
271+
272+
function EnablePreviewSdks() {
273+
$vsInfo = LocateVisualStudio
274+
if ($vsInfo -eq $null) {
275+
# Preview SDKs are allowed when no Visual Studio instance is installed
276+
Write-Host "No Visual Studio installation found; skipping enabling preview SDKs"
277+
return
278+
}
279+
280+
$vsId = $vsInfo.instanceId
281+
$vsMajorVersion = $vsInfo.installationVersion.Split('.')[0]
282+
283+
$instanceDir = Join-Path ${env:USERPROFILE} "AppData\Local\Microsoft\VisualStudio\$vsMajorVersion.0_$vsId"
284+
Create-Directory $instanceDir
285+
$sdkFile = Join-Path $instanceDir "sdk.txt"
286+
Write-Host "Enabling preview SDKs by writing to $sdkFile"
287+
'UsePreviews=True' | Set-Content $sdkFile
288+
}

eng/build.ps1

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -534,22 +534,6 @@ function TestUsingRunTests() {
534534
}
535535
}
536536

537-
function EnablePreviewSdks() {
538-
$vsInfo = LocateVisualStudio
539-
if ($vsInfo -eq $null) {
540-
# Preview SDKs are allowed when no Visual Studio instance is installed
541-
return
542-
}
543-
544-
$vsId = $vsInfo.instanceId
545-
$vsMajorVersion = $vsInfo.installationVersion.Split('.')[0]
546-
547-
$instanceDir = Join-Path ${env:USERPROFILE} "AppData\Local\Microsoft\VisualStudio\$vsMajorVersion.0_$vsId"
548-
Create-Directory $instanceDir
549-
$sdkFile = Join-Path $instanceDir "sdk.txt"
550-
'UsePreviews=True' | Set-Content $sdkFile
551-
}
552-
553537
# Deploy our core VSIX libraries to Visual Studio via the Roslyn VSIX tool. This is an alternative to
554538
# deploying at build time.
555539
function Deploy-VsixViaTool() {

eng/enable-preview-sdks.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Set-StrictMode -version 2.0
2+
$ErrorActionPreference="Stop"
3+
4+
. (Join-Path $PSScriptRoot "build-utils.ps1")
5+
6+
EnablePreviewSdks

src/Compilers/Core/MSBuildTaskTests/TestUtilities/IntegrationTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected static ProcessResult RunCommandLineCompiler(
119119
additionalEnvironmentVars);
120120
}
121121

122-
[Theory(Skip = "https://github.com/dotnet/roslyn/issues/81246"), CombinatorialData]
122+
[Theory, CombinatorialData]
123123
public void SdkBuild_Csc(bool useSharedCompilation)
124124
{
125125
var result = RunMsbuild(
@@ -151,7 +151,7 @@ class Program { static void Main() { System.Console.WriteLine("Hello from file")
151151
Assert.Contains(ExecutionConditionUtil.IsWindows ? "csc.exe" : "csc", result.Output);
152152
}
153153

154-
[Theory(Skip = "https://github.com/dotnet/roslyn/issues/81246"), CombinatorialData]
154+
[Theory, CombinatorialData]
155155
public void SdkBuild_Vbc(bool useSharedCompilation)
156156
{
157157
var result = RunMsbuild(

src/Tools/Source/RunTests/HelixTestRunner.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ static void AppendHelixWorkItemProject(
215215
Path.Combine(workItemPayloadDir, rspFileName),
216216
GetRspFileContent(assemblyRelativeFilePaths, helixWorkItem.TestMethodNames, platform));
217217

218+
Directory.CreateSymbolicLink(
219+
path: Path.Combine(workItemPayloadDir, "eng"),
220+
pathToTarget: Path.Combine(artifactsDir, "..", "eng"));
221+
File.CreateSymbolicLink(
222+
path: Path.Combine(workItemPayloadDir, "global.json"),
223+
pathToTarget: Path.Combine(artifactsDir, "..", "global.json"));
224+
218225
var (commandFileName, commandContent) = GetHelixCommandContent(assemblyRelativeFilePaths, rspFileName, testOS);
219226
File.WriteAllText(Path.Combine(workItemPayloadDir, commandFileName), commandContent);
220227

@@ -282,6 +289,8 @@ static void AppendHelixWorkItemProject(
282289

283290
command.AppendLine(isUnix ? "env | sort" : "set");
284291

292+
command.AppendLine("powershell -ExecutionPolicy ByPass -NoProfile -File ./eng/enable-preview-sdks.ps1");
293+
285294
// Rehydrate assemblies that we need to run as part of this work item.
286295
foreach (var assemblyRelativeFilePath in assemblyRelativeFilePaths)
287296
{

0 commit comments

Comments
 (0)