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
15 changes: 15 additions & 0 deletions src/installer/tests/Assets/TestProjects/StandaloneApp6x/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace StandaloneApp
{
public static class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>StandaloneApp</AssemblyName>
<TargetFrameworks>net6.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RuntimeIdentifier>$(TestTargetRid)</RuntimeIdentifier>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void ComponentWithNoDependenciesCaseChangedOnAsm()
// Linux: we fail
// Windows and Mac, probing succeeds but
// Windows: probing returns the original name
// Mac: probing return the new name including 2 assembly probing with the same new name and the changed deps file
// Mac: probing return the new name including 2 assembly probing with the original and new name, and the changed deps file

var component = sharedTestState.ComponentWithNoDependencies.Copy();

Expand Down Expand Up @@ -89,7 +89,7 @@ public void ComponentWithNoDependenciesCaseChangedOnAsm()
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{component.AppDll}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]")
.And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'")
.And.HaveStdErrContaining($"deps='{changeDepsFile}'")
.And.HaveStdErrContaining($"mgd_app='{changeFile}'");
Expand All @@ -115,7 +115,7 @@ public void ComponentWithNoDependenciesCaseChangedOnDepsAndAsm()
// Linux: we fail
// Windows and Mac, probing succeeds but
// Windows: probing returns the original name
// Mac: probing return the new name including 2 assembly probing with the same new name and the changed deps file
// Mac: probing return the new name including 2 assembly probing with the original and new name, and the changed deps file

var component = sharedTestState.ComponentWithNoDependencies.Copy();

Expand Down Expand Up @@ -146,7 +146,7 @@ public void ComponentWithNoDependenciesCaseChangedOnDepsAndAsm()
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{component.AppDll}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]")
.And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'")
.And.HaveStdErrContaining($"deps='{changeDepsFile}'")
.And.HaveStdErrContaining($"mgd_app='{changeFile}'");
Expand Down Expand Up @@ -242,7 +242,8 @@ public void ComponentWithDependencies()
$"{Path.Combine(sharedTestState.ComponentWithDependencies.Location, "Newtonsoft.Json.dll")}{Path.PathSeparator}]")
.And.HaveStdOutContaining(
$"corehost_resolve_component_dependencies native_search_paths:[" +
$"{ExpectedProbingPaths(Path.Combine(sharedTestState.ComponentWithDependencies.Location, "runtimes", "win10-x86", "native"))}]");
$"{Path.Combine(sharedTestState.ComponentWithDependencies.Location, "runtimes", "win10-x86", "native")}" +
$"{Path.DirectorySeparatorChar}{Path.PathSeparator}]");
}

[Fact]
Expand All @@ -251,14 +252,14 @@ public void ComponentWithDependenciesAndDependencyRemoved()
var component = sharedTestState.ComponentWithDependencies.Copy();

// Remove a dependency
// This will cause the resolution to fail
File.Delete(Path.Combine(component.Location, "ComponentDependency.dll"));

sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining(
$"corehost_resolve_component_dependencies assemblies:[" +
$"{Path.Combine(component.Location, "ComponentDependency.dll")}{Path.PathSeparator}" +
$"{component.AppDll}{Path.PathSeparator}" +
$"{Path.Combine(component.Location, "Newtonsoft.Json.dll")}{Path.PathSeparator}]");
}
Expand Down Expand Up @@ -369,36 +370,8 @@ public void ComponentWithResourcesShouldReportResourceSearchPaths()
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies resource_search_paths:[" +
$"{ExpectedProbingPaths(sharedTestState.ComponentWithResources.Location)}]");
}

private string ExpectedProbingPaths(params string[] paths)
{
string result = string.Empty;
foreach (string path in paths)
{
string expectedPath = path;
if (expectedPath.EndsWith(Path.DirectorySeparatorChar))
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// On non-windows the paths are normalized to not end with a /
expectedPath = expectedPath.Substring(0, expectedPath.Length - 1);
}
}
else
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// On windows all paths are normalized to end with a \
expectedPath += Path.DirectorySeparatorChar;
}
}

result += expectedPath + Path.PathSeparator;
}

return result;
$"{sharedTestState.ComponentWithResources.Location}" +
$"{Path.DirectorySeparatorChar}{Path.PathSeparator}]");
}

[Fact]
Expand All @@ -425,7 +398,8 @@ public void MultiThreadedComponentDependencyResolutionWhichSucceeeds()
.And.HaveStdOutContaining($"ComponentA: corehost_resolve_component_dependencies assemblies:[{sharedTestState.ComponentWithNoDependencies.AppDll}{Path.PathSeparator}]")
.And.HaveStdOutContaining($"ComponentB: corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"ComponentB: corehost_resolve_component_dependencies resource_search_paths:[" +
$"{ExpectedProbingPaths(sharedTestState.ComponentWithResources.Location)}]");
$"{sharedTestState.ComponentWithResources.Location}" +
$"{Path.DirectorySeparatorChar}{Path.PathSeparator}]");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void BasicApp()
CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNet.BinPath)
.Execute();

string pathSuffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Path.DirectorySeparatorChar.ToString() : string.Empty;
string pathSuffix = Path.DirectorySeparatorChar.ToString();
string expectedSearchDirectories =
Path.GetDirectoryName(sharedState.AppPath) + pathSuffix + Path.PathSeparator +
Path.Combine(sharedState.DotNet.BinPath, "shared", "Microsoft.NETCore.App", SharedTestState.NetCoreAppVersion) + pathSuffix + Path.PathSeparator;
Expand Down
Loading