Skip to content

Commit 5a86952

Browse files
committed
Use RestoreAdditionalProjectSources for SB tests
1 parent 483c975 commit 5a86952

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

eng/pipelines/templates/stages/vmr-verticals.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,7 @@ stages:
10301030
extraProperties: >
10311031
/p:DotNetSourceOnlyTestOnly=true
10321032
/p:ExtraRestoreSourcePath=$(Pipeline.Workspace)/msft-pkgs
1033-
/p:SourceBuildTestsCustomSourceBuiltPackagesPath=$(Pipeline.Workspace)/msft-pkgs
1034-
/p:SourceBuildTestsCustomSourceBuiltPackagesPathIsInclusive=true
1033+
/p:RestoreAdditionalProjectSources=$(Pipeline.Workspace)/msft-pkgs
10351034
dependsOn:
10361035
- AzureLinux_x64_Cross_x64
10371036
- Browser_Shortstack_wasm

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ internal static class Config
2020
public static string LogsDirectory => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(LogsDirectory))! ?? throw new InvalidOperationException("Logs directory must be specified");
2121

2222
public static string? CustomPackagesPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(CustomPackagesPath))!;
23-
public static bool CustomPackagesPathIsInclusive => bool.TryParse((string)AppContext.GetData(ConfigSwitchPrefix + nameof(CustomPackagesPathIsInclusive))!, out bool customPackagesPathIsInclusive) && customPackagesPathIsInclusive;
2423
public static bool ExcludeOmniSharpTests => bool.TryParse((string)AppContext.GetData(ConfigSwitchPrefix + nameof(ExcludeOmniSharpTests))!, out bool excludeOmniSharpTests) && excludeOmniSharpTests;
2524
public static string? LicenseScanPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(LicenseScanPath))!;
2625
public static string? MsftSdkTarballPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(MsftSdkTarballPath))!;
2726
public static string? PoisonReportPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(PoisonReportPath))!;
2827
public static string? SdkTarballPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(SdkTarballPath))!;
2928
public static string? SourceBuiltArtifactsPath => (string)AppContext.GetData(ConfigSwitchPrefix + nameof(SourceBuiltArtifactsPath))!;
29+
public static string? RestoreAdditionalProjectSources => (string?)AppContext.GetData(ConfigSwitchPrefix + nameof(RestoreAdditionalProjectSources));
3030

3131
// Indicates whether the tests are being run in the context of a CI pipeline
3232
public static bool RunningInCI => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_CI")) ||

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/DotNetHelper.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public DotNetHelper(ITestOutputHelper outputHelper)
4949
private static void InitNugetConfig()
5050
{
5151
bool useCustomPackages = !string.IsNullOrEmpty(Config.CustomPackagesPath);
52-
string nugetConfigPrefix = useCustomPackages && !Config.CustomPackagesPathIsInclusive ? "custom" : "default";
52+
string nugetConfigPrefix = useCustomPackages ? "custom" : "default";
5353
string nugetConfigPath = Path.Combine(ProjectsDirectory, "NuGet.Config");
5454
File.Copy(
5555
Path.Combine(BaselineHelper.GetAssetsDirectory(), $"{nugetConfigPrefix}.NuGet.Config"),
@@ -68,13 +68,6 @@ private static void InitNugetConfig()
6868
.Replace("CUSTOM_PACKAGE_FEED", Config.CustomPackagesPath);
6969
File.WriteAllText(nugetConfigPath, nugetConfig);
7070
}
71-
else
72-
{
73-
// Clear out the unused custom package feed
74-
string nugetConfig = File.ReadAllText(nugetConfigPath)
75-
.Replace("<add key=\"custom-packages\" value=\"CUSTOM_PACKAGE_FEED\" />", "");
76-
File.WriteAllText(nugetConfigPath, nugetConfig);
77-
}
7871
}
7972

8073
public void ExecuteCmd(string args, string? workingDirectory = null, Action<Process>? processConfigCallback = null,
@@ -117,8 +110,11 @@ public static void ConfigureProcess(Process process, string? workingDirectory)
117110
process.StartInfo.EnvironmentVariables["ImportDirectoryPackagesProps"] = "false";
118111
}
119112

120-
public void ExecuteBuild(string projectName) =>
121-
ExecuteCmd($"build {GetBinLogOption(projectName, "build")}", GetProjectDirectory(projectName));
113+
public void ExecuteBuild(string projectName)
114+
{
115+
string options = $"/p:RestoreAdditionalProjectSources={Config.RestoreAdditionalProjectSources}";
116+
ExecuteCmd($"build {options} {GetBinLogOption(projectName, "build")}", GetProjectDirectory(projectName));
117+
}
122118

123119
/// <summary>
124120
/// Create a new .NET project and return the path to the created project folder.
@@ -143,12 +139,12 @@ public string ExecuteNew(string projectType, string name, string? language = nul
143139

144140
public void ExecutePublish(string projectName, DotNetTemplate template, bool? selfContained = null, string? rid = null, bool trimmed = false, bool readyToRun = false)
145141
{
146-
string options = string.Empty;
142+
string options = $"/p:RestoreAdditionalProjectSources={Config.RestoreAdditionalProjectSources}";
147143
string binlogDifferentiator = string.Empty;
148144

149145
if (selfContained.HasValue)
150146
{
151-
options += $"--self-contained {selfContained.Value.ToString().ToLowerInvariant()}";
147+
options += $" --self-contained {selfContained.Value.ToString().ToLowerInvariant()}";
152148
if (selfContained.Value)
153149
{
154150
binlogDifferentiator += "self-contained";

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/Microsoft.DotNet.SourceBuild.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).CustomPackagesPath">
6363
<Value>$(SourceBuildTestsCustomSourceBuiltPackagesPath)</Value>
6464
</RuntimeHostConfigurationOption>
65-
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).CustomPackagesPathIsInclusive">
66-
<Value>$(SourceBuildTestsCustomSourceBuiltPackagesPathIsInclusive)</Value>
67-
</RuntimeHostConfigurationOption>
6865
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).ExcludeOmniSharpTests">
6966
<Value>$(SourceBuildTestsExcludeOmniSharpTests)</Value>
7067
</RuntimeHostConfigurationOption>
@@ -84,6 +81,9 @@
8481
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).SourceBuiltArtifactsPath">
8582
<Value>$(SourceBuiltArtifactsPath)</Value>
8683
</RuntimeHostConfigurationOption>
84+
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).RestoreAdditionalProjectSources">
85+
<Value>$(RestoreAdditionalProjectSources)</Value>
86+
</RuntimeHostConfigurationOption>
8787
</ItemGroup>
8888
</Target>
8989

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/assets/default.NuGet.Config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
<add key="darc-pub-dotnet-runtime-d398172" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-d3981726/nuget/v3/index.json" />
99
<add key="dotnet10" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json" />
1010
<add key="dotnet10-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json" />
11-
<add key="custom-packages" value="CUSTOM_PACKAGE_FEED" />
1211
</packageSources>
1312
</configuration>

0 commit comments

Comments
 (0)