示例#1
0
        public void It_excludes_ni_pdbs_from_single_file()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                // R2R doesn't produce ni pdbs on OSX.
                return;
            }

            var publishCommand = GetPublishCommand();

            publishCommand
            .Execute(PublishSingleFile, RuntimeIdentifier, IncludeAllContent, ReadyToRun, ReadyToRunWithSymbols)
            .Should()
            .Pass();

            string         targetFramework = ToolsetInfo.CurrentTargetFramework;
            NuGetFramework framework       = NuGetFramework.Parse(targetFramework);

            var intermediateDirectory = publishCommand.GetIntermediateDirectory(targetFramework, runtimeIdentifier: RuntimeInformation.RuntimeIdentifier);
            var mainProjectDll        = Path.Combine(intermediateDirectory.FullName, $"{TestProjectName}.dll");
            var niPdbFile             = GivenThatWeWantToPublishReadyToRun.GetPDBFileName(mainProjectDll, framework, RuntimeInformation.RuntimeIdentifier);

            string[] expectedFiles = { SingleFile, PdbFile, niPdbFile };
            GetPublishDirectory(publishCommand)
            .Should()
            .OnlyHaveFiles(expectedFiles);
        }
        public void ILLink_and_crossgen_process_razor_assembly()
        {
            var targetFramework = "netcoreapp3.0";
            var rid             = EnvironmentInfo.GetCompatibleRid(targetFramework);

            var testProject = new TestProject
            {
                Name             = "TestWeb",
                IsSdkProject     = true,
                IsExe            = true,
                ProjectSdk       = "Microsoft.NET.Sdk.Web",
                TargetFrameworks = targetFramework,
                SourceFiles      =
                {
                    ["Program.cs"]  = @"
                        class Program
                        {
                            static void Main() {}
                        }",
                    ["Test.cshtml"] = @"
                        @page
                        @{
                            System.IO.Compression.ZipFile.OpenRead(""test.zip"");
                        }
                    ",
                },
                AdditionalProperties =
                {
                    ["RuntimeIdentifier"] = rid,
                    ["PublishTrimmed"]    = "true",
                    ["PublishReadyToRun"] = "true",
                }
            };

            var testAsset      = _testAssetsManager.CreateTestProject(testProject);
            var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));

            publishCommand.Execute().Should().Pass();

            var publishDir = publishCommand.GetOutputDirectory(targetFramework, runtimeIdentifier: rid);

            publishDir.Should().HaveFile("System.IO.Compression.ZipFile.dll");
            GivenThatWeWantToPublishReadyToRun.DoesImageHaveR2RInfo(publishDir.File("TestWeb.Views.dll").FullName);
        }