public void Muxer_activation_of_Publish_Output_Portable_DLL_hostfxr_get_native_search_directories_Succeeds() { // Currently the native API is used only on Windows, although it has been manually tested on Unix. // Limit OS here to avoid issues with DllImport not being able to find the shared library. if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } var fixture = PreviouslyPublishedAndRestoredPortableTestProjectFixture.Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; var dotnetLocation = Path.Combine(dotnet.BinPath, $"dotnet{fixture.ExeExtension}"); string[] args = { "hostfxr_get_native_search_directories", dotnetLocation, appDll }; dotnet.Exec(appDll, args) .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("hostfxr_get_native_search_directories:Success") .And .HaveStdOutContaining("hostfxr_get_native_search_directories buffer:[" + dotnet.GreatestVersionSharedFxPath); }
public void Muxer_activation_of_Publish_Output_Portable_DLL_with_DepsJson_and_RuntimeConfig_Local_Succeeds() { var fixture = PreviouslyPublishedAndRestoredPortableTestProjectFixture .Copy(); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; dotnet.Exec(appDll) .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World"); dotnet.Exec("exec", appDll) .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World"); }
public void Framework_Dependent_AppHost_Succeeds() { var fixture = PreviouslyPublishedAndRestoredPortableTestProjectFixture .Copy(); // Since SDK doesn't support building framework dependent apphost yet, emulate that behavior // by creating the executable from apphost.exe var appExe = fixture.TestProject.AppExe; var appDllName = Path.GetFileName(fixture.TestProject.AppDll); string hostExeName = $"apphost{Constants.ExeSuffix}"; string builtAppHost = Path.Combine(RepoDirectories.HostArtifacts, hostExeName); string appDir = Path.GetDirectoryName(appExe); string appDirHostExe = Path.Combine(appDir, hostExeName); // Make a copy of apphost first, replace hash and overwrite app.exe, rather than // overwrite app.exe and edit in place, because the file is opened as "write" for // the replacement -- the test fails with ETXTBSY (exit code: 26) in Linux when // executing a file opened in "write" mode. File.Copy(builtAppHost, appDirHostExe, true); using (var sha256 = SHA256.Create()) { // Replace the hash with the managed DLL name. var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes("foobar")); var hashStr = BitConverter.ToString(hash).Replace("-", "").ToLower(); AppHostExtensions.SearchAndReplace(appDirHostExe, Encoding.UTF8.GetBytes(hashStr), Encoding.UTF8.GetBytes(appDllName), true); } File.Copy(appDirHostExe, appExe, true); // Get the framework location that was built string builtDotnet = fixture.BuiltDotnet.BinPath; // Verify running with the default working directory Command.Create(appExe) .CaptureStdErr() .CaptureStdOut() .EnvironmentVariable("DOTNET_ROOT", builtDotnet) .EnvironmentVariable("DOTNET_ROOT(x86)", builtDotnet) .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World"); // Verify running from within the working directory Command.Create(appExe) .WorkingDirectory(fixture.TestProject.OutputDirectory) .EnvironmentVariable("DOTNET_ROOT", builtDotnet) .EnvironmentVariable("DOTNET_ROOT(x86)", builtDotnet) .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World"); }
public void Muxer_Exec_activation_of_Publish_Output_Portable_DLL_with_DepsJson_Remote_and_RuntimeConfig_Local_Fails() { var fixture = PreviouslyPublishedAndRestoredPortableTestProjectFixture .Copy(); MoveDepsJsonToSubdirectory(fixture); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; var depsJson = fixture.TestProject.DepsJson; dotnet.Exec("exec", "--depsfile", depsJson, appDll) .CaptureStdErr() .CaptureStdOut() .Execute(fExpectedToFail: true) .Should() .Fail(); }
public void Muxer_Exec_activation_of_Publish_Output_Portable_DLL_with_DepsJson_Local_and_RuntimeConfig_Remote_Succeeds() { var fixture = PreviouslyPublishedAndRestoredPortableTestProjectFixture .Copy(); MoveRuntimeConfigToSubdirectory(fixture); var dotnet = fixture.BuiltDotnet; var appDll = fixture.TestProject.AppDll; var runtimeConfig = fixture.TestProject.RuntimeConfigJson; dotnet.Exec("exec", "--runtimeconfig", runtimeConfig, appDll) .CaptureStdErr() .CaptureStdOut() .Execute() .Should() .Pass() .And .HaveStdOutContaining("Hello World"); }