Esempio n. 1
0
        public void It_has_target_path_and_final_outputput_path_metadata(string targetFramework)
        {
            var testAsset = _testAssetsManager
                            .CopyTestAsset("HelloWorld", identifier: targetFramework)
                            .WithSource()
                            .WithTargetFramework(targetFramework);

            var command = new GetValuesCommand(
                Log,
                testAsset.TestRoot,
                targetFramework,
                "BuiltProjectOutputGroupOutput",
                GetValuesCommand.ValueType.Item)
            {
                MetadataNames    = { "FinalOutputPath", "TargetPath" },
                DependsOnTargets = "BuiltProjectOutputGroup",
            };

            command.Execute().Should().Pass();

            var outputDirectory   = command.GetOutputDirectory(targetFramework);
            var runtimeConfigFile = outputDirectory.File("HelloWorld.runtimeconfig.json");

            var(_, metadata) = command.GetValuesWithMetadata().Single(i => i.value == runtimeConfigFile.FullName);

            metadata.Count.Should().Be(2);
            metadata.Should().Contain(KeyValuePair.Create("FinalOutputPath", runtimeConfigFile.FullName));
            metadata.Should().Contain(KeyValuePair.Create("TargetPath", runtimeConfigFile.Name));
        }
Esempio n. 2
0
        public void It_builds_a_simple_project(string targetFramework)
        {
            if (targetFramework == "net45" && !TestProject.ReferenceAssembliesAreInstalled("v4.5"))
            {
                // skip net45 when we do not have .NET Framework 4.5 reference assemblies
                // due to https://github.com/dotnet/core-sdk/issues/3228
                return;
            }

            var(expectedVBRuntime, expectedOutputFiles) = GetExpectedOutputs(targetFramework);

            var testProject = new TestProject
            {
                Name                 = "HelloWorld",
                IsSdkProject         = true,
                TargetFrameworks     = targetFramework,
                IsExe                = targetFramework != "netstandard2.0",
                AdditionalProperties =
                {
                    ["MyType"] = "Console",
                },
                SourceFiles =
                {
                    ["Program.vb"] = @"
                        Imports System

                        Module Program
                            Function MyComputerName() As String
                                #If NETFRAMEWORK Or NETCOREAPP3_0 Then
                                    Return My.Computer.Name
                                #End If
                            End Function

                            Sub Main(args As String())
                                Console.WriteLine(""Hello World from "" & MyComputerName())
                            End Sub
                        End Module
                        ",
                }
            };

            var testAsset = _testAssetsManager
                            .CreateTestProject(testProject, identifier: targetFramework, targetExtension: ".vbproj")
                            .Restore(Log, testProject.Name);

            var buildCommand = new GetValuesCommand(
                Log,
                Path.Combine(testAsset.TestRoot, testProject.Name),
                targetFramework,
                "VBRuntime")
            {
                DependsOnTargets = "Build"
            };

            buildCommand
            .Execute()
            .Should()
            .Pass();

            var outputDirectory = buildCommand.GetOutputDirectory(targetFramework);
            var actualVBRuntime = GetVBRuntime(buildCommand.GetValues().FirstOrDefault());

            File.Delete(outputDirectory.File("VBRuntimeValues.txt").FullName);

            outputDirectory.Should().OnlyHaveFiles(expectedOutputFiles);
            actualVBRuntime.Should().Be(expectedVBRuntime);
        }
Esempio n. 3
0
        public void It_builds_a_simple_vb_project(string targetFramework, bool isExe)
        {
            var(expectedVBRuntime, expectedOutputFiles) = GetExpectedOutputs(targetFramework, isExe);

            var testProject = new TestProject
            {
                Name             = "HelloWorld",
                IsSdkProject     = true,
                TargetFrameworks = targetFramework,
                IsExe            = isExe,
                SourceFiles      =
                {
                    ["Program.vb"] = @"
                        Imports System

                        Module Program
                            #If NETFRAMEWORK Or NETCOREAPP3_0
                                ' https://github.com/dotnet/sdk/issues/2793
                                Private Const TabChar As Char = Chr(9)
                            #End If

                            Function MyComputerName() As String
                                #If NETFRAMEWORK
                                    Return My.Computer.Name
                                #End If

                                #If NETFRAMEWORK Or NETCOREAPP_3_0
                                    ' https://github.com/dotnet/sdk/issues/3379
                                    End
                                #End If
                            End Function

                            Sub Main(args As String())
                                Console.WriteLine(""Hello World from "" & MyComputerName())
                            End Sub
                        End Module
                        ",
                }
            };

            var testAsset = _testAssetsManager
                            .CreateTestProject(testProject, identifier: targetFramework + isExe, targetExtension: ".vbproj");

            var buildCommand = new GetValuesCommand(
                Log,
                Path.Combine(testAsset.TestRoot, testProject.Name),
                targetFramework,
                "VBRuntime")
            {
                DependsOnTargets = "Build"
            };

            buildCommand
            .Execute()
            .Should()
            .Pass();

            var outputDirectory = buildCommand.GetOutputDirectory(targetFramework);
            var actualVBRuntime = GetVBRuntime(buildCommand.GetValues().FirstOrDefault());

            File.Delete(outputDirectory.File("VBRuntimeValues.txt").FullName);

            outputDirectory.Should().OnlyHaveFiles(expectedOutputFiles);
            actualVBRuntime.Should().Be(expectedVBRuntime);
        }