PR feedback:
- Remove setting VSTestUseMSBuildOutput - Set DotnetHostPath in runsettings - Silence output if using msbuild logger - Remove nuget config - Don't publish self-contained
This commit is contained in:
parent
60306f3cbb
commit
6acbd2fd35
5 changed files with 28 additions and 20 deletions
|
@ -33,6 +33,5 @@
|
||||||
<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>
|
||||||
<MicrosoftExtensionsFileSystemGlobbingVersion>8.0.0</MicrosoftExtensionsFileSystemGlobbingVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -150,11 +150,10 @@
|
||||||
|
|
||||||
<Target Name="RunUnifiedBuildValidation"
|
<Target Name="RunUnifiedBuildValidation"
|
||||||
AfterTargets="Build"
|
AfterTargets="Build"
|
||||||
Condition="'$(PortableBuild)' == 'true' and '$(PgoInstrument)' != 'true' and '$(DotNetBuildSourceOnly)' != 'true'" >
|
Condition="'$(PortableBuild)' == 'true' and '$(PgoInstrument)' != 'true' and '$(DotNetBuildSourceOnly)' != 'true'">
|
||||||
<MSBuild Projects="../test/Microsoft.DotNet.UnifiedBuild.Tests/Microsoft.DotNet.UnifiedBuild.Tests.csproj"
|
<MSBuild Projects="../test/Microsoft.DotNet.UnifiedBuild.Tests/Microsoft.DotNet.UnifiedBuild.Tests.csproj"
|
||||||
Targets="VSTest"
|
Targets="VSTest"
|
||||||
ContinueOnError="true"
|
ContinueOnError="true" />
|
||||||
Properties="VsTestUseMSBuildOutput=true" />
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class Config : IDisposable
|
||||||
public string TargetRid { get; }
|
public string TargetRid { get; }
|
||||||
public string TargetArchitecture { get; }
|
public string TargetArchitecture { get; }
|
||||||
public bool WarnOnSdkContentDiffs { get; }
|
public bool WarnOnSdkContentDiffs { get; }
|
||||||
|
public bool NoDiagnosticMessages { get; }
|
||||||
|
|
||||||
string? _downloadedMsftSdkPath = null;
|
string? _downloadedMsftSdkPath = null;
|
||||||
IMessageSink _sink;
|
IMessageSink _sink;
|
||||||
|
@ -29,6 +30,8 @@ public class Config : IDisposable
|
||||||
public Config(IMessageSink sink)
|
public Config(IMessageSink sink)
|
||||||
{
|
{
|
||||||
_sink = sink;
|
_sink = sink;
|
||||||
|
string? noDiagnosticMessages = (string?)AppContext.GetData(NoDiagnosticMessagesSwitch);
|
||||||
|
NoDiagnosticMessages = string.IsNullOrEmpty(noDiagnosticMessages) ? false : bool.Parse(noDiagnosticMessages);
|
||||||
UbBuildVersion = (string)(AppContext.GetData(BuildVersionSwitch) ?? throw new InvalidOperationException("Unified Build version must be specified"));
|
UbBuildVersion = (string)(AppContext.GetData(BuildVersionSwitch) ?? throw new InvalidOperationException("Unified Build version must be specified"));
|
||||||
TargetRid = (string)(AppContext.GetData(TargetRidSwitch) ?? throw new InvalidOperationException("Target RID must be specified"));
|
TargetRid = (string)(AppContext.GetData(TargetRidSwitch) ?? throw new InvalidOperationException("Target RID must be specified"));
|
||||||
PortableRid = (string)(AppContext.GetData(PortableRidSwitch) ?? throw new InvalidOperationException("Portable RID must be specified"));
|
PortableRid = (string)(AppContext.GetData(PortableRidSwitch) ?? throw new InvalidOperationException("Portable RID must be specified"));
|
||||||
|
@ -41,9 +44,9 @@ public class Config : IDisposable
|
||||||
MsftSdkArchivePath = DownloadMsftSdkArchive().Result;
|
MsftSdkArchivePath = DownloadMsftSdkArchive().Result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sink.OnMessage(new DiagnosticMessage($"Skipping downloading latest SDK. Using provided sdk archive: '{MsftSdkArchivePath}'"));
|
LogMessage($"Skipping downloading latest SDK. Using provided sdk archive: '{MsftSdkArchivePath}'");
|
||||||
}
|
}
|
||||||
sink.OnMessage(new DiagnosticMessage($$"""
|
LogMessage($$"""
|
||||||
Test config values:
|
Test config values:
|
||||||
{{nameof(UbBuildVersion)}}='{{UbBuildVersion}}'
|
{{nameof(UbBuildVersion)}}='{{UbBuildVersion}}'
|
||||||
{{nameof(TargetRid)}}='{{TargetRid}}'
|
{{nameof(TargetRid)}}='{{TargetRid}}'
|
||||||
|
@ -52,7 +55,8 @@ public class Config : IDisposable
|
||||||
{{nameof(TargetArchitecture)}}='{{TargetArchitecture}}'
|
{{nameof(TargetArchitecture)}}='{{TargetArchitecture}}'
|
||||||
{{nameof(WarnOnSdkContentDiffs)}}='{{WarnOnSdkContentDiffs}}'
|
{{nameof(WarnOnSdkContentDiffs)}}='{{WarnOnSdkContentDiffs}}'
|
||||||
{{nameof(MsftSdkArchivePath)}}='{{MsftSdkArchivePath}}'
|
{{nameof(MsftSdkArchivePath)}}='{{MsftSdkArchivePath}}'
|
||||||
"""));
|
{{nameof(NoDiagnosticMessages)}}='{{NoDiagnosticMessages}}'
|
||||||
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
const string ConfigSwitchPrefix = "Microsoft.DotNet.UnifiedBuild.Tests.";
|
const string ConfigSwitchPrefix = "Microsoft.DotNet.UnifiedBuild.Tests.";
|
||||||
|
@ -62,6 +66,7 @@ public class Config : IDisposable
|
||||||
const string UbSdkArchivePathSwitch = ConfigSwitchPrefix + nameof(UbSdkArchivePath);
|
const string UbSdkArchivePathSwitch = ConfigSwitchPrefix + nameof(UbSdkArchivePath);
|
||||||
const string MsftSdkArchivePathSwitch = ConfigSwitchPrefix + nameof(MsftSdkArchivePath);
|
const string MsftSdkArchivePathSwitch = ConfigSwitchPrefix + nameof(MsftSdkArchivePath);
|
||||||
const string WarnOnSdkContentDiffsSwitch = ConfigSwitchPrefix + nameof(WarnOnSdkContentDiffs);
|
const string WarnOnSdkContentDiffsSwitch = ConfigSwitchPrefix + nameof(WarnOnSdkContentDiffs);
|
||||||
|
const string NoDiagnosticMessagesSwitch = ConfigSwitchPrefix + nameof(NoDiagnosticMessages);
|
||||||
|
|
||||||
static string GetArchiveExtension(string path)
|
static string GetArchiveExtension(string path)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +82,7 @@ public class Config : IDisposable
|
||||||
var client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
|
var client = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
|
||||||
var channel = UbBuildVersion[..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}'"));
|
LogMessage($"Downloading latest sdk from '{akaMsUrl}'");
|
||||||
var redirectResponse = await client.GetAsync(akaMsUrl);
|
var redirectResponse = await client.GetAsync(akaMsUrl);
|
||||||
// aka.ms returns a 301 for valid redirects and a 302 to Bing for invalid URLs
|
// aka.ms returns a 301 for valid redirects and a 302 to Bing for invalid URLs
|
||||||
if (redirectResponse.StatusCode != HttpStatusCode.Moved)
|
if (redirectResponse.StatusCode != HttpStatusCode.Moved)
|
||||||
|
@ -85,17 +90,28 @@ public class Config : IDisposable
|
||||||
throw new InvalidOperationException($"Could not find download link for Microsoft built sdk at '{akaMsUrl}'");
|
throw new InvalidOperationException($"Could not find download link for Microsoft built sdk at '{akaMsUrl}'");
|
||||||
}
|
}
|
||||||
var closestUrl = redirectResponse.Headers.Location!.ToString();
|
var closestUrl = redirectResponse.Headers.Location!.ToString();
|
||||||
_sink.OnMessage(new DiagnosticMessage($"Redirected to '{closestUrl}'"));
|
LogMessage($"Redirected to '{closestUrl}'");
|
||||||
HttpResponseMessage packageResponse = await client.GetAsync(closestUrl);
|
HttpResponseMessage packageResponse = await client.GetAsync(closestUrl);
|
||||||
var packageUriPath = packageResponse.RequestMessage!.RequestUri!.LocalPath;
|
var packageUriPath = packageResponse.RequestMessage!.RequestUri!.LocalPath;
|
||||||
_downloadedMsftSdkPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + Path.GetFileName(packageUriPath));
|
_downloadedMsftSdkPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + Path.GetFileName(packageUriPath));
|
||||||
_sink.OnMessage(new DiagnosticMessage($"Downloading to '{_downloadedMsftSdkPath}'"));
|
LogMessage($"Downloading to '{_downloadedMsftSdkPath}'");
|
||||||
using (var file = File.Create(_downloadedMsftSdkPath))
|
using (var file = File.Create(_downloadedMsftSdkPath))
|
||||||
{
|
{
|
||||||
await packageResponse.Content.CopyToAsync(file);
|
await packageResponse.Content.CopyToAsync(file);
|
||||||
}
|
}
|
||||||
return _downloadedMsftSdkPath;
|
return _downloadedMsftSdkPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogMessage(string message)
|
||||||
|
{
|
||||||
|
if (NoDiagnosticMessages)
|
||||||
|
return;
|
||||||
|
if (_sink is null)
|
||||||
|
throw new InvalidOperationException("Cannot log message without a message sink");
|
||||||
|
|
||||||
|
_sink.OnMessage(new DiagnosticMessage(message));
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_downloadedMsftSdkPath != null)
|
if (_downloadedMsftSdkPath != null)
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
<VSTestLogger>console%3bverbosity=diagnostic;trx%3bverbosity=diagnostic%3bLogFileName=Microsoft.DotNet.UnifiedBuild.Tests.xml</VSTestLogger>
|
<VSTestLogger>console%3bverbosity=diagnostic;trx%3bverbosity=diagnostic%3bLogFileName=Microsoft.DotNet.UnifiedBuild.Tests.xml</VSTestLogger>
|
||||||
<VSTestResultsDirectory>$(ArtifactsTestResultsDir)</VSTestResultsDirectory>
|
<VSTestResultsDirectory>$(ArtifactsTestResultsDir)</VSTestResultsDirectory>
|
||||||
<VsTestUseMSBuildOutput>true</VsTestUseMSBuildOutput>
|
<VsTestUseMSBuildOutput>true</VsTestUseMSBuildOutput>
|
||||||
<!-- DOTNET_ROOT is not set when running the test, so the testhost looks in the global installation location for preview framework assemblies, which aren't there -->
|
<VSTestCLIRunSettings>$(VSTestCLIRunSettings);RunConfiguration.DotNetHostPath=$(DotnetTool)</VSTestCLIRunSettings>
|
||||||
<!-- As a workaround, just publish self-contained to copy the framework assemblies from the local sdk -->
|
|
||||||
<SelfContained>true</SelfContained>
|
|
||||||
<RuntimeIdentifier>$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</RuntimeIdentifier>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -46,6 +43,9 @@
|
||||||
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.MsftSdkArchivePath">
|
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.MsftSdkArchivePath">
|
||||||
<Value>$(UBTestsMsftSdkArchivePath)</Value>
|
<Value>$(UBTestsMsftSdkArchivePath)</Value>
|
||||||
</RuntimeHostConfigurationOption>
|
</RuntimeHostConfigurationOption>
|
||||||
|
<RuntimeHostConfigurationOption Include="Microsoft.DotNet.UnifiedBuild.Tests.NoDiagnosticMessages">
|
||||||
|
<Value>$(VSTestUseMSBuildOutput)</Value>
|
||||||
|
</RuntimeHostConfigurationOption>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
Loading…
Add table
Add a link
Reference in a new issue