Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/installer/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@
The NuGet fallback folder can/will contain packages we are building in this repo, and we
want to ensure we use the correct packages. -->
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<UseBootstrapLayout Condition="'$(UseBootstrap)' == 'true'">true</UseBootstrapLayout>
</PropertyGroup>

<!-- Bootstrap layout is used when we don't have an LKG apphost to rely on, like on freebsd. -->
<PropertyGroup Condition="'$(UseBootstrapLayout)' == 'true'">
<UseLocalAppHostPack Condition="'$(UseBootstrapLayout)' == 'true'">true</UseLocalAppHostPack>
<UseLocalTargetingRuntimePack Condition="'$(UseBootstrapLayout)' == 'true'">false</UseLocalTargetingRuntimePack>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions src/installer/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>

<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(UseBootstrapLayout)' == 'true'" />

<PropertyGroup>
<InstallerName>$(InstallerName)</InstallerName>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/installer/pkg/sfx/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<EnsureRuntimeIdentifierSet>true</EnsureRuntimeIdentifierSet>
<UseLocalTargetingRuntimePack>true</UseLocalTargetingRuntimePack>
</PropertyGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
<Import Project="$(Crossgen2SdkOverridePropsPath)" Condition="'$(PublishReadyToRun)' == 'true' and '$(Crossgen2SdkOverridePropsPath)' != ''" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.SharedFramework.Sdk" />
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" />
<Import Project="$(RepositoryEngineeringDir)codeOptimization.targets" />
<Import Project="$(Crossgen2SdkOverrideTargetsPath)" Condition="'$(PublishReadyToRun)' == 'true' and '$(Crossgen2SdkOverrideTargetsPath)' != ''" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

<PropertyGroup>
<Description>Apphost Bundle Tests</Description>
<OutputType>Exe</OutputType>
<RuntimeIdentifier>$(TargetRid)</RuntimeIdentifier>
<TargetFramework>$(TestInfraTargetFramework)</TargetFramework>
<AssemblyName>AppHost.Bundle.Tests</AssemblyName>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
<TestsOutputName>ahb</TestsOutputName>
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
<NoWarn>$(NoWarn);NU1511;xUnit1004</NoWarn>
<TestRunnerName>XUnitV3</TestRunnerName>
</PropertyGroup>

<ItemGroup>
Expand Down
35 changes: 19 additions & 16 deletions src/installer/tests/AppHost.Bundle.Tests/AppLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void RunTheApp(string path, bool selfContained)
Command.Create(path)
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World!");
Expand Down Expand Up @@ -75,10 +75,10 @@ private void RunApp(bool selfContained)
if (OperatingSystem.IsWindows())
{
// StandaloneApp sets FileVersion to NETCoreApp version. On Windows, this should be copied to singlefilehost resources.
string expectedVersion = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: TestContext.MicrosoftNETCoreAppVersion;
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: HostTestContext.MicrosoftNETCoreAppVersion;
Assert.Equal($"{expectedVersion}.0", System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
}
}

Expand All @@ -103,14 +103,17 @@ private void NonAsciiCharacterSelfContainedApp()
if (OperatingSystem.IsWindows())
{
// StandaloneApp sets FileVersion to NETCoreApp version. On Windows, this should be copied to singlefilehost resources.
string expectedVersion = TestContext.MicrosoftNETCoreAppVersion.Contains('-')
? TestContext.MicrosoftNETCoreAppVersion[..TestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: TestContext.MicrosoftNETCoreAppVersion;
Assert.Equal(expectedVersion, System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
string expectedVersion = HostTestContext.MicrosoftNETCoreAppVersion.Contains('-')
? HostTestContext.MicrosoftNETCoreAppVersion[..HostTestContext.MicrosoftNETCoreAppVersion.IndexOf('-')]
: HostTestContext.MicrosoftNETCoreAppVersion;
Assert.Equal($"{expectedVersion}.0", System.Diagnostics.FileVersionInfo.GetVersionInfo(singleFile).FileVersion);
}
}

[ConditionalTheory(typeof(Binaries.CetCompat), nameof(Binaries.CetCompat.IsSupported))]
[Theory(
SkipType = typeof(Binaries.CetCompat),
SkipUnless = nameof(Binaries.CetCompat.IsSupported),
Skip = "CET is not supported on this platform")]
[InlineData(true)]
[InlineData(false)]
public void DisableCetCompat(bool selfContained)
Expand All @@ -124,12 +127,12 @@ public void DisableCetCompat(bool selfContained)
Command.Create(singleFile)
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(TestContext.BuiltDotNet.BinPath, TestContext.BuildArchitecture)
.DotNetRoot(HostTestContext.BuiltDotNet.BinPath, HostTestContext.BuildArchitecture)
.MultilevelLookup(false)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining(TestContext.MicrosoftNETCoreAppVersion);
.And.HaveStdOutContaining(HostTestContext.MicrosoftNETCoreAppVersion);
}

[Theory]
Expand Down Expand Up @@ -158,7 +161,7 @@ public void FrameworkDependent_NoBundleEntryPoint()

using (var dotnetWithMockHostFxr = TestArtifact.Create("mockhostfxrFrameworkMissingFailure"))
{
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
.RemoveHostFxr()
.AddMockHostFxr(new Version(2, 2, 0))
.Build();
Expand All @@ -177,7 +180,7 @@ public void FrameworkDependent_NoBundleEntryPoint()
}

[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // GUI app host is only supported on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
{
var singleFile = sharedTestState.FrameworkDependentApp.Bundle();
Expand All @@ -188,14 +191,14 @@ public void FrameworkDependent_GUI_DownlevelHostFxr_ErrorDialog()
{
string expectedErrorCode = Constants.ErrorCode.BundleExtractionFailure.ToString("x");

var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, TestContext.BuiltDotNet.BinPath, null)
var dotnet = new DotNetBuilder(dotnetWithMockHostFxr.Location, HostTestContext.BuiltDotNet.BinPath, null)
.RemoveHostFxr()
.AddMockHostFxr(new Version(5, 0, 0))
.Build();

Command command = Command.Create(singleFile)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(dotnet.BinPath, TestContext.BuildArchitecture)
.DotNetRoot(dotnet.BinPath, HostTestContext.BuildArchitecture)
.Start();

WindowsUtils.WaitForPopupFromProcess(command.Process);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private FluentAssertions.AndConstraint<CommandResultAssertions> RunTheApp(string
{
CommandResult result = Command.Create(path)
.EnableTracingAndCaptureOutputs()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
.MultilevelLookup(false)
.Execute();
if (deleteApp)
Expand Down
4 changes: 2 additions & 2 deletions src/installer/tests/AppHost.Bundle.Tests/NativeLibraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private void PInvoke(bool selfContained, bool bundleNative)
Command.Create(app, "load_native_library_pinvoke")
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
// Specify an extraction root that will get cleaned up by the test app artifact
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, extractionRoot)
.Execute()
Expand Down Expand Up @@ -66,7 +66,7 @@ private void TryLoad(bool selfContained, bool bundleNative)
Command.Create(app, "load_native_library_api")
.CaptureStdErr()
.CaptureStdOut()
.DotNetRoot(selfContained ? null : TestContext.BuiltDotNet.BinPath)
.DotNetRoot(selfContained ? null : HostTestContext.BuiltDotNet.BinPath)
// Specify an extraction root that will get cleaned up by the test app artifact
.EnvironmentVariable(Constants.BundleExtractBase.EnvironmentVariable, extractionRoot)
.Execute()
Expand Down
5 changes: 2 additions & 3 deletions src/installer/tests/Assets/Projects/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project>
<Import Project="$(RepositoryEngineeringDir)liveBuilds.targets" />
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" />

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agocke this change looks wrong. Now these projects don't import the parent Directory.Build.targets file anymore but still the parent Directory.Build.props file.

Copy link
Member

@ViktorHofer ViktorHofer Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this as part of #121853 as properties like NETCoreAppMaximumVersion are not correctly set anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I think that’s right. These are test assets. I don’t think they should be importing the upwards targets file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be possible to import a specific targets file that provides a minimum set of functionality that we think should apply to tests, but the whole point of these projects is that they should be "normal" .NET projects that an everyday user would see. We do not want our targets files arbitrarily polluting their space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then they shouldn't even import any of the upwards props files. They must work without any of our custom defined settings. Also some of our props files must even have targets in them. I think you get my point. We need to be in synchronicity between D.B.props and D.B.targets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's probably right -- I didn't realize they import the props files. They shouldn't do that either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


<PropertyGroup>
<UseAppHost Condition="'$(UseAppHost)' == '' and '$(SelfContained)' != 'true'">false</UseAppHost>
<UseAppHost Condition="'$(SelfContained)' != 'true'">false</UseAppHost>
</PropertyGroup>

<!-- Override target from targetingpacks.targets. Use Version instead of ProductVersion (written into runtimeconfig.json).
Expand Down
9 changes: 4 additions & 5 deletions src/installer/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<PropertyGroup>
<TestArtifactsOutputRoot>$(ArtifactsDir)tests\host\$(TargetOS).$(TargetArchitecture).$(Configuration)\</TestArtifactsOutputRoot>
<TestInfraTargetFramework>$(NetCoreAppToolCurrent)</TestInfraTargetFramework>
<TestCaseFilter>category!=failing</TestCaseFilter>
<TestRunnerAdditionalArguments>--filter $(TestCaseFilter) -v detailed</TestRunnerAdditionalArguments>
<TestCaseFilter>/[category!=failing]</TestCaseFilter>
<TestRunnerAdditionalArguments>--filter-query $(TestCaseFilter)</TestRunnerAdditionalArguments>
<!-- Enable crash and hang dumps -->
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-crash-dump-type full</TestRunnerAdditionalArguments>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --blame-hang-timeout 5m --blame-hang-dump-type full</TestRunnerAdditionalArguments>
<UseVSTestRunner>true</UseVSTestRunner>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --crashdump</TestRunnerAdditionalArguments>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --hangdump --hangdump-timeout 5m --hangdump-type full</TestRunnerAdditionalArguments>
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>

Expand Down
5 changes: 5 additions & 0 deletions src/installer/tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<RunSettingsTestCaseFilter>$(TestCaseFilter)</RunSettingsTestCaseFilter>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="1.7.3" />
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" Version="1.7.3" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)testing\runsettings.targets"
Condition="'$(IsTestProject)' == 'true'" />

Expand Down
4 changes: 2 additions & 2 deletions src/installer/tests/HostActivation.Tests/Breadcrumbs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Breadcrumbs(SharedTestState fixture)
[Fact]
public void BreadcrumbThreadFinishes()
{
TestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll)
HostTestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll)
.EnvironmentVariable(Constants.Breadcrumbs.EnvironmentVariable, sharedTestState.BreadcrumbLocation)
.EnableTracingAndCaptureOutputs()
.Execute()
Expand All @@ -34,7 +34,7 @@ public void BreadcrumbThreadFinishes()
[Fact]
public void UnhandledException_BreadcrumbThreadDoesNotFinish()
{
TestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll, "throw_exception")
HostTestContext.BuiltDotNet.Exec(sharedTestState.App.AppDll, "throw_exception")
.EnvironmentVariable(Constants.Breadcrumbs.EnvironmentVariable, sharedTestState.BreadcrumbLocation)
.EnableTracingAndCaptureOutputs()
.DisableDumps() // Expected to throw an exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,24 @@ public class SharedTestState : SharedTestStateBase
public SharedTestState()
{
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
.Build();

string nativeDependencyRelPath = $"{TestContext.BuildRID}/{Binaries.GetSharedLibraryFileNameForCurrentPlatform("native")}";
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, b => b
string nativeDependencyRelPath = $"{HostTestContext.BuildRID}/{Binaries.GetSharedLibraryFileNameForCurrentPlatform("native")}";
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, b => b
.WithProject(DependencyName, DependencyVersion, p => p
.WithAssemblyGroup(null, g => g
.WithAsset($"{DependencyName}.dll", f => f.NotOnDisk()))
.WithNativeLibraryGroup(TestContext.BuildRID, g => g
.WithNativeLibraryGroup(HostTestContext.BuildRID, g => g
.WithAsset(nativeDependencyRelPath, f => f.NotOnDisk()))));
RuntimeConfig.FromFile(FrameworkReferenceApp.RuntimeConfigJson)
.WithTfm(TestContext.Tfm)
.WithTfm(HostTestContext.Tfm)
.Save();

AdditionalProbingPath = Path.Combine(Location, "probe");
(DependencyPath, NativeDependencyDirectory) = AddDependencies(AdditionalProbingPath);

AdditionalProbingPath_ArchTfm = Path.Combine(AdditionalProbingPath, TestContext.BuildArchitecture, TestContext.Tfm);
AdditionalProbingPath_ArchTfm = Path.Combine(AdditionalProbingPath, HostTestContext.BuildArchitecture, HostTestContext.Tfm);
(DependencyPath_ArchTfm, NativeDependencyDirectory_ArchTfm) = AddDependencies(AdditionalProbingPath_ArchTfm);

(string, string) AddDependencies(string probeDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public class SharedTestState : SharedTestStateBase
public SharedTestState()
{
DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(TestContext.MicrosoftNETCoreAppVersion)
.AddMicrosoftNETCoreAppFrameworkMockCoreClr(HostTestContext.MicrosoftNETCoreAppVersion)
.Build();

FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, TestContext.MicrosoftNETCoreAppVersion, b => b
FrameworkReferenceApp = CreateFrameworkReferenceApp(Constants.MicrosoftNETCoreApp, HostTestContext.MicrosoftNETCoreAppVersion, b => b
.WithProject(DependencyName, "1.0.0", p => p
.WithAssemblyGroup(null, g => g.WithAsset($"{DependencyName}.dll"))));

Expand Down
Loading
Loading