From 9412ecb25150e18b4b7d2694647839f74eba3bf2 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Fri, 4 Jun 2021 11:51:57 -0700 Subject: [PATCH 1/8] Enable loading composite r2r images from a singlefile bundle --- src/coreclr/utilcode/pedecoder.cpp | 6 ++++-- src/coreclr/vm/nativeimage.cpp | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 3b46c56a41587..46f0339d67e27 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1039,7 +1039,8 @@ CHECK PEDecoder::CheckCorHeader() const // If the file is COM+ 1.0, which by definition has nothing the runtime can // use, or if the file requires a newer version of this engine than us, // it cannot be run by this engine. - CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); + // TODO: WIP composite r2r violate this, perhps should be fixed. + // CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); CHECK(CheckDirectory(&pCor->MetaData, IMAGE_SCN_MEM_WRITE, HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); CHECK(CheckDirectory(&pCor->Resources, IMAGE_SCN_MEM_WRITE, NULL_OK)); @@ -1085,7 +1086,8 @@ CHECK PEDecoder::CheckCorHeader() const // only they can have a native image header if ((pCor->Flags&VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) == 0) { - CHECK(VAL32(pCor->ManagedNativeHeader.Size) == 0); + // TODO: WIP composite r2r violate this, perhps should be fixed. + // CHECK(VAL32(pCor->ManagedNativeHeader.Size) == 0); } // Metadata header checks diff --git a/src/coreclr/vm/nativeimage.cpp b/src/coreclr/vm/nativeimage.cpp index 5500da1acc872..06644d9a842f1 100644 --- a/src/coreclr/vm/nativeimage.cpp +++ b/src/coreclr/vm/nativeimage.cpp @@ -145,7 +145,9 @@ NativeImage *NativeImage::Open( EX_TRY { - peLoadedImage = PEImageLayout::LoadNative(fullPath); + BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(fullPath, /*pathIsBundleRelative */ true); + PEImageHolder pImage = PEImage::OpenImage(fullPath, MDInternalImport_NoCache, bundleFileLocation); + peLoadedImage = pImage->GetLayout(PEImageLayout::LAYOUT_MAPPED, PEImage::LAYOUT_CREATEIFNEEDED); } EX_CATCH { From e6b127c0140079788f4685b19eaecc4344977bd3 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Mon, 7 Jun 2021 19:07:14 -0700 Subject: [PATCH 2/8] fix for Linux. --- src/coreclr/vm/nativeimage.cpp | 98 ++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/src/coreclr/vm/nativeimage.cpp b/src/coreclr/vm/nativeimage.cpp index 06644d9a842f1..8338dbc60960b 100644 --- a/src/coreclr/vm/nativeimage.cpp +++ b/src/coreclr/vm/nativeimage.cpp @@ -143,61 +143,69 @@ NativeImage *NativeImage::Open( NewHolder peLoadedImage; - EX_TRY + BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(fullPath, /*pathIsBundleRelative */ true); + if (bundleFileLocation.IsValid()) { - BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(fullPath, /*pathIsBundleRelative */ true); PEImageHolder pImage = PEImage::OpenImage(fullPath, MDInternalImport_NoCache, bundleFileLocation); peLoadedImage = pImage->GetLayout(PEImageLayout::LAYOUT_MAPPED, PEImage::LAYOUT_CREATEIFNEEDED); } - EX_CATCH + + if (peLoadedImage.IsNull()) { - SString searchPaths(searchPathsConfig); - SString::CIterator start = searchPaths.Begin(); - while (start != searchPaths.End()) + EX_TRY { - SString::CIterator end = start; - if (!searchPaths.Find(end, PATH_SEPARATOR_CHAR_W)) - { - end = searchPaths.End(); - } - fullPath.Set(searchPaths, start, (COUNT_T)(end - start)); - - if (end != searchPaths.End()) - { - // Skip path separator character - ++end; - } - start = end; - - if (fullPath.GetCount() == 0) - { - continue; - } - - fullPath.Append(DIRECTORY_SEPARATOR_CHAR_W); - fullPath += compositeImageFileName; - - EX_TRY - { - peLoadedImage = PEImageLayout::LoadNative(fullPath); - break; - } - EX_CATCH + peLoadedImage = PEImageLayout::LoadNative(fullPath); + } + EX_CATCH + { + SString searchPaths(searchPathsConfig); + SString::CIterator start = searchPaths.Begin(); + while (start != searchPaths.End()) { + SString::CIterator end = start; + if (!searchPaths.Find(end, PATH_SEPARATOR_CHAR_W)) + { + end = searchPaths.End(); + } + fullPath.Set(searchPaths, start, (COUNT_T)(end - start)); + + if (end != searchPaths.End()) + { + // Skip path separator character + ++end; + } + start = end; + + if (fullPath.GetCount() == 0) + { + continue; + } + + fullPath.Append(DIRECTORY_SEPARATOR_CHAR_W); + fullPath += compositeImageFileName; + + EX_TRY + { + peLoadedImage = PEImageLayout::LoadNative(fullPath); + break; + } + EX_CATCH + { + } + EX_END_CATCH(SwallowAllExceptions) } - EX_END_CATCH(SwallowAllExceptions) } - } - EX_END_CATCH(SwallowAllExceptions) + EX_END_CATCH(SwallowAllExceptions) - if (peLoadedImage.IsNull()) - { - // Failed to locate the native composite R2R image - LOG((LF_LOADER, LL_ALWAYS, "LOADER: failed to load native image '%s' for component assembly '%S' using search paths: '%S'\n", - nativeImageFileName, - path.GetUnicode(), - searchPathsConfig != nullptr ? searchPathsConfig : W(""))); - RaiseFailFastException(nullptr, nullptr, 0); + if (peLoadedImage.IsNull()) + { + // Failed to locate the native composite R2R image + LOG((LF_LOADER, LL_ALWAYS, "LOADER: failed to load native image '%s' for component assembly '%S' using search paths: '%S'\n", + nativeImageFileName, + path.GetUnicode(), + searchPathsConfig != nullptr ? searchPathsConfig : W(""))); + RaiseFailFastException(nullptr, nullptr, 0); + } } READYTORUN_HEADER *pHeader = (READYTORUN_HEADER *)peLoadedImage->GetExport("RTR_HEADER"); From f81e82a041dc6dc05b86fc77b9c5e6212eb593e2 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Thu, 10 Jun 2021 14:23:07 -0700 Subject: [PATCH 3/8] relax pedecoder checks to accept known violations in r2r composite images --- src/coreclr/utilcode/pedecoder.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 46f0339d67e27..1ded8107ec10c 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1034,15 +1034,25 @@ CHECK PEDecoder::CheckCorHeader() const IMAGE_COR20_HEADER *pCor = GetCorHeader(); + // Currently composite r2r images miss some information, for example the version is 0.0. + // We may want to change that to something more conforming and explicit. + // For now, for compatibility purposes, we will accept that as a valid format. + bool possiblyCompositeR2R = + pCor->MinorRuntimeVersion == 0 && + pCor->MajorRuntimeVersion == 0; + //CHECK(((ULONGLONG)pCor & 0x3)==0); // If the file is COM+ 1.0, which by definition has nothing the runtime can // use, or if the file requires a newer version of this engine than us, // it cannot be run by this engine. - // TODO: WIP composite r2r violate this, perhps should be fixed. - // CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); + if (!possiblyCompositeR2R) + CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); - CHECK(CheckDirectory(&pCor->MetaData, IMAGE_SCN_MEM_WRITE, HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); + CHECK(CheckDirectory( + &pCor->MetaData, + possiblyCompositeR2R ? 0 : IMAGE_SCN_MEM_WRITE, + HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); CHECK(CheckDirectory(&pCor->Resources, IMAGE_SCN_MEM_WRITE, NULL_OK)); CHECK(CheckDirectory(&pCor->StrongNameSignature, IMAGE_SCN_MEM_WRITE, NULL_OK)); CHECK(CheckDirectory(&pCor->CodeManagerTable, IMAGE_SCN_MEM_WRITE, NULL_OK)); @@ -1084,10 +1094,9 @@ CHECK PEDecoder::CheckCorHeader() const // IL library files (really a misnomer - these are native images or ReadyToRun images) // only they can have a native image header - if ((pCor->Flags&VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) == 0) + if ((pCor->Flags&VAL32(COMIMAGE_FLAGS_IL_LIBRARY)) == 0 && !possiblyCompositeR2R) { - // TODO: WIP composite r2r violate this, perhps should be fixed. - // CHECK(VAL32(pCor->ManagedNativeHeader.Size) == 0); + CHECK(VAL32(pCor->ManagedNativeHeader.Size) == 0); } // Metadata header checks @@ -1771,7 +1780,7 @@ void PEDecoder::LayoutILOnly(void *base, bool enableExecution) const PAGE_READONLY, &oldProtection)) ThrowLastError(); - // Finally, apply proper protection to copied sections + // Finally, apply proper protection to copied sections for (section = sectionStart; section < sectionEnd; section++) { // Add appropriate page protection. From f77b9784d52ed7bfb7586d3b912ff6a9597cdc87 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Thu, 10 Jun 2021 14:51:45 -0700 Subject: [PATCH 4/8] keep IMAGE_SCN_MEM_WRITE disallowed on windows. --- src/coreclr/utilcode/pedecoder.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/utilcode/pedecoder.cpp b/src/coreclr/utilcode/pedecoder.cpp index 1ded8107ec10c..639cb02099bf4 100644 --- a/src/coreclr/utilcode/pedecoder.cpp +++ b/src/coreclr/utilcode/pedecoder.cpp @@ -1049,10 +1049,14 @@ CHECK PEDecoder::CheckCorHeader() const if (!possiblyCompositeR2R) CHECK(VAL16(pCor->MajorRuntimeVersion) > 1 && VAL16(pCor->MajorRuntimeVersion) <= COR_VERSION_MAJOR); +#ifdef HOST_WINDOWS + CHECK(CheckDirectory(&pCor->MetaData, IMAGE_SCN_MEM_WRITE, HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); +#else CHECK(CheckDirectory( &pCor->MetaData, possiblyCompositeR2R ? 0 : IMAGE_SCN_MEM_WRITE, HasNativeHeader() ? NULL_OK : NULL_NOT_OK)); +#endif CHECK(CheckDirectory(&pCor->Resources, IMAGE_SCN_MEM_WRITE, NULL_OK)); CHECK(CheckDirectory(&pCor->StrongNameSignature, IMAGE_SCN_MEM_WRITE, NULL_OK)); CHECK(CheckDirectory(&pCor->CodeManagerTable, IMAGE_SCN_MEM_WRITE, NULL_OK)); From ce31d9caf4a39d2624dd27cebe1e96fc7650f856 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Fri, 11 Jun 2021 10:53:42 -0700 Subject: [PATCH 5/8] adding a test --- .../BundledAppWithSubDirs.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index 9ede20c516e39..ce62f1149fd96 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -126,6 +126,25 @@ public void Bundled_Self_Contained_Targeting50_WithCompression_Throws() Assert.Throws(()=>BundleHelper.BundleApp(fixture, options, new Version(5, 0))); } + [Fact] + public void Bundled_Self_Contained_Composite_App_Run_Succeeds() + { + using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); + testSelfContainedFixtureComposite + .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), + selfContained: true, + restore: true, + extraArgs: new string[] { + "/p:PublishReadyToRun=true", + "/p:PublishReadyToRunComposite=true"}); + + var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + + // Run the app + RunTheApp(singleFile, testSelfContainedFixtureComposite); + } + [InlineData(BundleOptions.None)] [InlineData(BundleOptions.BundleNativeBinaries)] [InlineData(BundleOptions.BundleAllContent)] From 968471a5a0e14639ba74d51b67d54e3cab905c27 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Fri, 11 Jun 2021 14:01:40 -0700 Subject: [PATCH 6/8] more tests --- .../BundledAppWithSubDirs.cs | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index ce62f1149fd96..e07c191b3c9f6 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -131,6 +131,7 @@ public void Bundled_Self_Contained_Composite_App_Run_Succeeds() { using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); testSelfContainedFixtureComposite + .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), selfContained: true, @@ -145,6 +146,104 @@ public void Bundled_Self_Contained_Composite_App_Run_Succeeds() RunTheApp(singleFile, testSelfContainedFixtureComposite); } + [Fact] + public void Bundled_Self_Contained_Composite_App_Run_Succeeds1() + { + using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); + testSelfContainedFixtureComposite + .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) + .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), + selfContained: true, + restore: true, + extraArgs: new string[] { + "", + ""}); + + var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + + // Run the app + RunTheApp(singleFile, testSelfContainedFixtureComposite); + } + + [Fact] + public void Bundled_Self_Contained_Composite_App_Run_Succeeds2() + { + using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); + testSelfContainedFixtureComposite + .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) + .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), + selfContained: true, + restore: true, + extraArgs: new string[] { + "/p:PublishReadyToRun=true", + ""}); + + var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + + // Run the app + RunTheApp(singleFile, testSelfContainedFixtureComposite); + } + + [Fact] + public void Bundled_Self_Contained_Composite_App_Run_Succeeds3() + { + using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); + testSelfContainedFixtureComposite + .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) + .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), + selfContained: true, + restore: true, + extraArgs: new string[] { + "", + "/p:PublishReadyToRunComposite=true"}); + + var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + + // Run the app + RunTheApp(singleFile, testSelfContainedFixtureComposite); + } + + [Fact] + public void Bundled_Self_Contained_Composite_App_Run_Succeeds4() + { + using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); + testSelfContainedFixtureComposite + .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), + selfContained: true, + restore: true, + extraArgs: new string[] { + "/p:PublishReadyToRun=true", + "/p:PublishReadyToRunComposite=true"}); + + var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + + // Run the app + RunTheApp(singleFile, testSelfContainedFixtureComposite); + } + + [Fact] + public void Bundled_Self_Contained_Composite_App_Run_Succeeds5() + { + using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); + testSelfContainedFixtureComposite + .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), + selfContained: true, + restore: true, + extraArgs: new string[] { + "", + ""}); + + var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + + // Run the app + RunTheApp(singleFile, testSelfContainedFixtureComposite); + } + [InlineData(BundleOptions.None)] [InlineData(BundleOptions.BundleNativeBinaries)] [InlineData(BundleOptions.BundleAllContent)] From 28dc2d3910e2be160bebdacc42f80885c9d848e6 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Fri, 11 Jun 2021 15:23:03 -0700 Subject: [PATCH 7/8] undo to the shared fixture --- .../BundledAppWithSubDirs.cs | 127 +++--------------- 1 file changed, 16 insertions(+), 111 deletions(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index e07c191b3c9f6..9d96dd619d1f9 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -129,119 +129,11 @@ public void Bundled_Self_Contained_Targeting50_WithCompression_Throws() [Fact] public void Bundled_Self_Contained_Composite_App_Run_Succeeds() { - using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); - testSelfContainedFixtureComposite - .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) - .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), - selfContained: true, - restore: true, - extraArgs: new string[] { - "/p:PublishReadyToRun=true", - "/p:PublishReadyToRunComposite=true"}); - - var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); - - // Run the app - RunTheApp(singleFile, testSelfContainedFixtureComposite); - } - - [Fact] - public void Bundled_Self_Contained_Composite_App_Run_Succeeds1() - { - using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); - testSelfContainedFixtureComposite - .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) - .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), - selfContained: true, - restore: true, - extraArgs: new string[] { - "", - ""}); - - var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); - - // Run the app - RunTheApp(singleFile, testSelfContainedFixtureComposite); - } - - [Fact] - public void Bundled_Self_Contained_Composite_App_Run_Succeeds2() - { - using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); - testSelfContainedFixtureComposite - .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) - .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), - selfContained: true, - restore: true, - extraArgs: new string[] { - "/p:PublishReadyToRun=true", - ""}); - - var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); - - // Run the app - RunTheApp(singleFile, testSelfContainedFixtureComposite); - } - - [Fact] - public void Bundled_Self_Contained_Composite_App_Run_Succeeds3() - { - using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); - testSelfContainedFixtureComposite - .EnsureRestoredForRid(testSelfContainedFixtureComposite.CurrentRid) - .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), - selfContained: true, - restore: true, - extraArgs: new string[] { - "", - "/p:PublishReadyToRunComposite=true"}); - - var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); - - // Run the app - RunTheApp(singleFile, testSelfContainedFixtureComposite); - } - - [Fact] - public void Bundled_Self_Contained_Composite_App_Run_Succeeds4() - { - using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); - testSelfContainedFixtureComposite - .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), - selfContained: true, - restore: true, - extraArgs: new string[] { - "/p:PublishReadyToRun=true", - "/p:PublishReadyToRunComposite=true"}); - - var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); + var fixture = sharedTestState.TestSelfContainedFixtureComposite.Copy(); + var singleFile = BundleSelfContainedApp(fixture, BundleOptions.None, disableCompression: true); // Run the app - RunTheApp(singleFile, testSelfContainedFixtureComposite); - } - - [Fact] - public void Bundled_Self_Contained_Composite_App_Run_Succeeds5() - { - using var testSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", new RepoDirectoriesProvider()); - testSelfContainedFixtureComposite - .PublishProject(runtime: testSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(testSelfContainedFixtureComposite), - selfContained: true, - restore: true, - extraArgs: new string[] { - "", - ""}); - - var singleFile = BundleSelfContainedApp(testSelfContainedFixtureComposite, BundleOptions.None, disableCompression: true); - - // Run the app - RunTheApp(singleFile, testSelfContainedFixtureComposite); + RunTheApp(singleFile, fixture); } [InlineData(BundleOptions.None)] @@ -262,6 +154,7 @@ public class SharedTestState : SharedTestStateBase, IDisposable public TestProjectFixture TestFrameworkDependentFixture { get; set; } public TestProjectFixture TestSelfContainedFixture { get; set; } public TestProjectFixture TestAppWithEmptyFileFixture { get; set; } + public TestProjectFixture TestSelfContainedFixtureComposite { get; set; } public SharedTestState() { @@ -287,6 +180,17 @@ public SharedTestState() .EnsureRestoredForRid(TestAppWithEmptyFileFixture.CurrentRid) .PublishProject(runtime: TestAppWithEmptyFileFixture.CurrentRid, outputDirectory: BundleHelper.GetPublishPath(TestAppWithEmptyFileFixture)); + + TestSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", RepoDirectories); + BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixtureComposite); + TestSelfContainedFixtureComposite + .EnsureRestoredForRid(TestSelfContainedFixtureComposite.CurrentRid) + .PublishProject(runtime: TestSelfContainedFixtureComposite.CurrentRid, + outputDirectory: BundleHelper.GetPublishPath(TestSelfContainedFixtureComposite), + extraArgs: new string[] { + "/p:PublishReadyToRun=true", + "/p:PublishReadyToRunComposite=true" }); + } public void Dispose() @@ -294,6 +198,7 @@ public void Dispose() TestFrameworkDependentFixture.Dispose(); TestSelfContainedFixture.Dispose(); TestAppWithEmptyFileFixture.Dispose(); + TestSelfContainedFixtureComposite.Dispose(); } } } From 547d84a16fdd1bcf83fffb5f085c1fb32be6784e Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Tue, 15 Jun 2021 12:02:20 -0700 Subject: [PATCH 8/8] disable the test for now --- .../AppHost.Bundle.Tests/BundledAppWithSubDirs.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index 9d96dd619d1f9..6621259213815 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -127,6 +127,8 @@ public void Bundled_Self_Contained_Targeting50_WithCompression_Throws() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/54234")] + // NOTE: when enabling this test take a look at commented code maked by "ACTIVE ISSUE:" in SharedTestState public void Bundled_Self_Contained_Composite_App_Run_Succeeds() { var fixture = sharedTestState.TestSelfContainedFixtureComposite.Copy(); @@ -186,11 +188,12 @@ public SharedTestState() TestSelfContainedFixtureComposite .EnsureRestoredForRid(TestSelfContainedFixtureComposite.CurrentRid) .PublishProject(runtime: TestSelfContainedFixtureComposite.CurrentRid, - outputDirectory: BundleHelper.GetPublishPath(TestSelfContainedFixtureComposite), + // ACTIVE ISSUE: https://github.com/dotnet/runtime/issues/54234 + // uncomment extraArgs when fixed. + outputDirectory: BundleHelper.GetPublishPath(TestSelfContainedFixtureComposite) /*, extraArgs: new string[] { "/p:PublishReadyToRun=true", - "/p:PublishReadyToRunComposite=true" }); - + "/p:PublishReadyToRunComposite=true" } */); } public void Dispose()