PR feedback

- Integrate runtime host config settings instead of EnvVars
- Move version to Versions.props
This commit is contained in:
Jackson Schuster 2024-03-25 14:12:53 -07:00
parent c592d1b570
commit 01e368ff71
4 changed files with 54 additions and 34 deletions

View file

@ -32,5 +32,6 @@
<MicrosoftExtensionsLoggingVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsLoggingVersion> <MicrosoftExtensionsLoggingVersion>9.0.0-preview.2.24128.5</MicrosoftExtensionsLoggingVersion>
<!-- command-line-api --> <!-- command-line-api -->
<SystemCommandLineVersion>2.0.0-beta4.24126.1</SystemCommandLineVersion> <SystemCommandLineVersion>2.0.0-beta4.24126.1</SystemCommandLineVersion>
<Microsoft_Extensions_FileSystemGlobbingVersion>7.0.0</Microsoft_Extensions_FileSystemGlobbingVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -9,24 +9,33 @@
AfterTargets="Build" AfterTargets="Build"
DependsOnTargets="DetermineSourceBuiltSdkVersion"> DependsOnTargets="DetermineSourceBuiltSdkVersion">
<ItemGroup>
<_UnifiedBuildValidationEnvVar Include="UNIFIED_BUILD_VALIDATION_SDK_TARBALL_PATH" Value="$(SdkTarballPath)" />
<_UnifiedBuildValidationEnvVar Include="UNIFIED_BUILD_VALIDATION_TARGET_RID" Value="$(TargetRid)" />
<_UnifiedBuildValidationEnvVar Include="UNIFIED_BUILD_VALIDATION_PORTABLE_RID" Value="$(PortableRid)" />
<_UnifiedBuildValidationEnvVar Include="UNIFIED_BUILD_VALIDATION_BUILD_VERSION" Value="$(SourceBuiltSdkVersion)" />
</ItemGroup>
<PropertyGroup> <PropertyGroup>
<SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath> <SdkTarballPath>%(SdkTarballItem.Identity)</SdkTarballPath>
<EnvironmentVariableRunSettings>@(_UnifiedBuildValidationEnvVar->'%(Identity)=%(Value)')</EnvironmentVariableRunSettings>
<runSettings>RunConfiguration.EnvironmentVariables.UNIFIED_BUILD_VALIDATION_ARGS=$([MSBuild]::Escape($(EnvironmentVariableRunSettings)))</runSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.UbSdkArchivePath">
<Value>$(SdkTarballPath)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.TargetRid">
<Value>$(TargetRid)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.PortableRid">
<Value>$(PortableRid)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.UbBuildVersion">
<Value>$(SourceBuiltSdkVersion)</Value>
</RuntimeHostConfigurationOption>
</ItemGroup>
<MSBuild Projects="$(UnifiedBuildValidationTestsProject)" <MSBuild Projects="$(UnifiedBuildValidationTestsProject)"
Targets="VSTest" Targets="VSTest"
Properties="VsTestUseMSBuildOutput=true; Properties="VsTestUseMSBuildOutput=true;
VSTestLogger=trx; VSTestLogger=trx;
VSTestCLIRunSettings=$(runSettings)" /> Microsoft_DotNet_UnifiedBuild_Tests_UbSdkArchivePath=$(SdkTarballPath);
Microsoft_DotNet_UnifiedBuild_Tests_TargetRid=$(TargetRid);
Microsoft_DotNet_UnifiedBuild_Tests_PortableRid=$(PortableRid);
Microsoft_DotNet_UnifiedBuild_Tests_SourceBuiltSdkVersion=$(SourceBuiltSdkVersion);" />
</Target> </Target>

View file

@ -18,29 +18,24 @@ public class Config : IDisposable
public Config(IMessageSink sink) public Config(IMessageSink sink)
{ {
_sink = sink; _sink = sink;
sink.OnMessage(new DiagnosticMessage($"Environment: '{Environment.GetEnvironmentVariable("UNIFIED_BUILD_VALIDATION_ARGS")}'")); UbBuildVersion = AppContext.GetSwitch(BuildVersionSwitch);
var env = Environment.GetEnvironmentVariable("UNIFIED_BUILD_VALIDATION_ARGS") ?? throw new InvalidOperationException("UNIFIED_BUILD_VALIDATION_ARGS must be specified"); ConfigPrefix = AppContext.GetSwitch(ConfigPrefixSwitch);
var envDict = env.Split(';').Select(s => s.Split('=')).ToDictionary(s => s[0], s => s[1]); TargetRid = AppContext.GetSwitch(TargetRidSwitch);
PortableRid = AppContext.GetSwitch(PortableRidSwitch);
BuildVersion = envDict[BuildVersionEnv]; UbSdkArchivePath = AppContext.GetSwitch(UbSdkArchivePathSwitch);
PortableRid = envDict[PortableRidEnv];
UbSdkArchivePath = envDict[UbSdkTarballPathEnv];
TargetRid = envDict[TargetRidEnv];
TargetArchitecture = TargetRid.Split('-')[1]; TargetArchitecture = TargetRid.Split('-')[1];
MsftSdkArchivePath = envDict.TryGetValue(MsftSdkTarballPathEnv, out var msftSdkPath) ? msftSdkPath : DownloadMsftSdkArchive().Result; MsftSdkArchivePath = AppContext.GetSwitch(MsftSdkArchivePathSwitch) ?? DownloadMsftSdkArchive().Result;
} }
public const string BuildVersionEnv = "UNIFIED_BUILD_VALIDATION_BUILD_VERSION"; public const string ConfigSwitchPrefix = "Microsoft.DotNet.UnifiedBuild.Tests.";
public const string MsftSdkTarballPathEnv = "UNIFIED_BUILD_VALIDATION_MSFT_SDK_TARBALL_PATH"; public const string BuildVersionSwitch = ConfigSwitchPrefix + nameof(UbBuildVersion);
public const string PortableRidEnv = "UNIFIED_BUILD_VALIDATION_PORTABLE_RID"; public const string TargetRidSwitch = ConfigSwitchPrefix + nameof(TargetRid);
public const string PrereqsPathEnv = "UNIFIED_BUILD_VALIDATION_PREREQS_PATH"; public const string PortableRidSwitch = ConfigSwitchPrefix + nameof(PortableRid);
public const string UbSdkTarballPathEnv = "UNIFIED_BUILD_VALIDATION_SDK_TARBALL_PATH"; public const string UbSdkArchivePathSwitch = ConfigSwitchPrefix + nameof(UbSdkArchivePath);
public const string SourceBuiltArtifactsPathEnv = "UNIFIED_BUILD_VALIDATION_SOURCEBUILT_ARTIFACTS_PATH"; public const string MsftSdkArchivePathSwitch = ConfigSwitchPrefix + nameof(MsftSdkArchivePath);
public const string TargetRidEnv = "UNIFIED_BUILD_VALIDATION_TARGET_RID";
public const string WarnSdkContentDiffsEnv = "UNIFIED_BUILD_VALIDATION_WARN_SDK_CONTENT_DIFFS";
public string? MsftSdkArchivePath { get; } public string? MsftSdkArchivePath { get; }
public string BuildVersion { get; } public string UbBuildVersion { get; }
public string PortableRid { get; } public string PortableRid { get; }
public string UbSdkArchivePath { get; } public string UbSdkArchivePath { get; }
public string TargetRid { get; } public string TargetRid { get; }
@ -60,7 +55,7 @@ public class Config : IDisposable
public async Task<string> DownloadMsftSdkArchive() public async Task<string> DownloadMsftSdkArchive()
{ {
var client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false }); var client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
var channel = BuildVersion[..5] + "xx"; var channel = UbBuildVersion[..5] + "xx";
var akaMsUrl = $"https://aka.ms/dotnet/{channel}/daily/dotnet-sdk-{TargetRid}{GetArchiveExtension(UbSdkArchivePath)}"; var akaMsUrl = $"https://aka.ms/dotnet/{channel}/daily/dotnet-sdk-{TargetRid}{GetArchiveExtension(UbSdkArchivePath)}";
_sink.OnMessage(new DiagnosticMessage($"Downloading latest sdk from '{akaMsUrl}'")); _sink.OnMessage(new DiagnosticMessage($"Downloading latest sdk from '{akaMsUrl}'"));
var redirectResponse = await client.GetAsync(akaMsUrl); var redirectResponse = await client.GetAsync(akaMsUrl);

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework> <TargetFramework>$(NetCurrent)</TargetFramework>
@ -7,14 +7,29 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(Microsoft_Extensions_FileSystemGlobbingVersion)" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="assets\**" <Content Include="assets\**" CopyToOutputDirectory="Always" />
CopyToOutputDirectory="Always" />
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" /> <Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.TargetRid">
<Value>$(Microsoft_DotNet_UnifiedBuild_Tests_TargetRid)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.PortableRid">
<Value>$(Microsoft_DotNet_UnifiedBuild_Tests_PortableRid)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.UbBuildVersion">
<Value>$(Microsoft_DotNet_UnifiedBuild_Tests_UbBuildVersion)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.UbSdkArchivePath">
<Value>$(Microsoft_DotNet_UnifiedBuild_Tests_UbSdkArchivePath)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.MsftSdkArchivePath">
<Value>$(Microsoft_DotNet_UnifiedBuild_Tests_MsftSdkArchivePath)</Value>
</RuntimeHostConfigurationOption>
</ItemGroup>
</Project> </Project>