public void It_resolves_desktop_apps_when_configuration_is_Debug()
        {
            var configuration = "Debug";

            var testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "AppWithProjTool2Fx")
                               .CreateInstance()
                               .WithSourceFiles()
                               .WithRestoreFiles();

            var buildCommand = new BuildCommand()
                               .WithWorkingDirectory(testInstance.Root)
                               .WithConfiguration(configuration)
                               .Execute()
                               .Should().Pass();

            var factory = new ProjectDependenciesCommandFactory(
                s_desktopTestFramework,
                configuration,
                null,
                null,
                testInstance.Root.FullName);

            var command = factory.Create("dotnet-desktop-and-portable", null);

            command.CommandName.Should().Contain(testInstance.Root.GetDirectory("bin", configuration).FullName);
            Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
        }
        public void It_resolves_desktop_apps_when_configuration_is_Debug()
        {
            var configuration = "Debug";

            var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
            var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyDesktopAndPortable")
                .WithLockFiles();

            var buildCommand = new BuildCommand(
                Path.Combine(testInstance.TestRoot, "project.json"),
                configuration: configuration)
                    .ExecuteWithCapturedOutput()
                    .Should()
                    .Pass();

            var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);

            var factory = new ProjectDependenciesCommandFactory(
                s_desktopTestFramework,
                configuration,
                null,
                null,
                testInstance.TestRoot);

            var command = factory.Create("dotnet-desktop-and-portable", null);

            command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
            Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
        }
        public void It_resolves_tools_whose_package_name_is_different_than_dll_name()
        {
            Environment.SetEnvironmentVariable(
                Constants.MSBUILD_EXE_PATH,
                Path.Combine(new RepoDirectoriesProvider().Stage2Sdk, "MSBuild.dll"));

            var configuration = "Debug";

            var testInstance = TestAssets.Get("AppWithDirectDepWithOutputName")
                               .CreateInstance()
                               .WithSourceFiles()
                               .WithRestoreFiles();

            var buildCommand = new BuildCommand()
                               .WithProjectDirectory(testInstance.Root)
                               .WithConfiguration(configuration)
                               .WithCapturedOutput()
                               .Execute()
                               .Should().Pass();

            var factory = new ProjectDependenciesCommandFactory(
                FrameworkConstants.CommonFrameworks.NetCoreApp10,
                configuration,
                null,
                null,
                testInstance.Root.FullName);

            var command = factory.Create("dotnet-tool-with-output-name", null);

            command.CommandArgs.Should().Contain(
                Path.Combine("toolwithoutputname", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
        }
예제 #4
0
        private static int InvokeDependencyTool(
            ProjectDependenciesCommandFactory commandFactory,
            DotnetBaseParams dotnetParams,
            NuGetFramework framework)
        {
            try
            {
                var exitCode = commandFactory.Create(
                    $"dotnet-{dotnetParams.Command}",
                    dotnetParams.RemainingArguments,
                    framework,
                    dotnetParams.Config)
                               .ForwardStdErr()
                               .ForwardStdOut()
                               .Execute()
                               .ExitCode;

                Console.WriteLine($"Command returned {exitCode}");
            }
            catch (CommandUnknownException)
            {
                Console.WriteLine($"Command not found");
                return(1);
            }

            return(0);
        }
예제 #5
0
        public void It_resolves_desktop_apps_defaulting_to_Debug_Configuration()
        {
            var configuration = "Debug";

            var testInstance = TestAssets.Get(TestAssetKinds.DesktopTestProjects, "AppWithProjTool2Fx")
                               .CreateInstance()
                               .WithSourceFiles()
                               .WithNuGetConfig(_repoDirectoriesProvider.TestPackages);

            var restoreCommand = new RestoreCommand()
                                 .WithWorkingDirectory(testInstance.Root)
                                 .ExecuteWithCapturedOutput()
                                 .Should().Pass();

            var buildCommand = new BuildCommand()
                               .WithWorkingDirectory(testInstance.Root)
                               .WithConfiguration(configuration)
                               .WithCapturedOutput()
                               .Execute()
                               .Should().Pass();

            var factory = new ProjectDependenciesCommandFactory(
                s_desktopTestFramework,
                null,
                null,
                null,
                testInstance.Root.FullName);

            var command = factory.Create("dotnet-desktop-and-portable", null);

            command.CommandName.Should().Contain(testInstance.Root.GetDirectory("bin", configuration).FullName);

            Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
        }
예제 #6
0
        public void It_resolves_desktop_apps_when_configuration_is_Release()
        {
            var configuration = "Release";

            var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "DesktopTestProjects"));
            var testInstance     = testAssetManager.CreateTestInstance("AppWithDirectDepDesktopAndPortable")
                                   .WithLockFiles();

            var buildCommand = new BuildCommand(
                Path.Combine(testInstance.TestRoot, "project.json"),
                configuration: configuration)
                               .ExecuteWithCapturedOutput()
                               .Should()
                               .Pass();

            var context = ProjectContext.Create(testInstance.TestRoot, s_desktopTestFramework);

            var factory = new ProjectDependenciesCommandFactory(
                s_desktopTestFramework,
                configuration,
                null,
                null,
                testInstance.TestRoot);

            var command = factory.Create("dotnet-desktop-and-portable", null);

            command.CommandName.Should().Contain(Path.Combine(testInstance.TestRoot, "bin", configuration));
            Path.GetFileName(command.CommandName).Should().Be("dotnet-desktop-and-portable.exe");
        }
예제 #7
0
        public void It_resolves_tools_whose_package_name_is_different_than_dll_name()
        {
            var configuration = "Debug";

            var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
            var testInstance     = testAssetManager.CreateTestInstance("AppWithDirectDepWithOutputName")
                                   .WithLockFiles();

            var buildCommand = new BuildCommand(
                Path.Combine(testInstance.TestRoot, "project.json"),
                configuration: configuration)
                               .ExecuteWithCapturedOutput()
                               .Should()
                               .Pass();

            var context = ProjectContext.Create(testInstance.TestRoot, FrameworkConstants.CommonFrameworks.NetCoreApp10);

            var factory = new ProjectDependenciesCommandFactory(
                FrameworkConstants.CommonFrameworks.NetCoreApp10,
                configuration,
                null,
                null,
                testInstance.TestRoot);

            var command = factory.Create("dotnet-tool-with-output-name", null);

            command.CommandArgs.Should().Contain(
                Path.Combine("toolwithoutputname", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
        }
예제 #8
0
파일: Program.cs 프로젝트: schellap/cli
        public static int Main(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            var dotnetParams = new DotnetBaseParams("dotnet-dependency-tool-invoker", "DotNet Dependency Tool Invoker", "Invokes tools declared as NuGet dependencies of a project");

            dotnetParams.Parse(args);

            if (string.IsNullOrEmpty(dotnetParams.Command))
            {
                Console.WriteLine("A command name must be provided");

                return(1);
            }

            var projectContexts =
                CreateProjectContexts(dotnetParams.ProjectPath)
                .Where(p => dotnetParams.Framework == null ||
                       dotnetParams.Framework.GetShortFolderName()
                       .Equals(p.TargetFramework.GetShortFolderName()));

            var commandFactory =
                new ProjectDependenciesCommandFactory(
                    dotnetParams.Framework,
                    dotnetParams.Config,
                    dotnetParams.Output,
                    dotnetParams.BuildBasePath,
                    projectContexts.First().ProjectDirectory);

            foreach (var projectContext in projectContexts)
            {
                Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{projectContext.TargetFramework}'.");

                try
                {
                    var exitCode = commandFactory.Create(
                        $"dotnet-{dotnetParams.Command}",
                        dotnetParams.RemainingArguments,
                        projectContext.TargetFramework,
                        dotnetParams.Config)
                                   .ForwardStdErr()
                                   .ForwardStdOut()
                                   .Execute()
                                   .ExitCode;

                    Console.WriteLine($"Command returned {exitCode}");
                }
                catch (CommandUnknownException)
                {
                    Console.WriteLine($"Command not found");
                    return(1);
                }
            }
            return(0);
        }
예제 #9
0
        public static int Main(string[] args)
        {
            return(StorytellerRunner.Program.Main(args));


            var dotnetParams = new DotnetBaseParams("dotnet-storyteller", "Storyteller Runner", "Run or edit Storyteller specifications");

            dotnetParams.Parse(args);

            var projectContexts =
                CreateProjectContexts(dotnetParams.ProjectPath)
                .Where(p => dotnetParams.Framework == null ||
                       dotnetParams.Framework.GetShortFolderName()
                       .Equals(p.TargetFramework.GetShortFolderName()));

            var commandFactory =
                new ProjectDependenciesCommandFactory(
                    dotnetParams.Framework,
                    dotnetParams.Config,
                    dotnetParams.Output,
                    dotnetParams.BuildBasePath,
                    projectContexts.First().ProjectDirectory);



            foreach (var projectContext in projectContexts)
            {
                Console.WriteLine($"Invoking '{dotnetParams.Command}' for '{projectContext.TargetFramework}'.");

                try
                {
                    var exitCode = commandFactory.Create(
                        $"StorytellerRunner",
                        dotnetParams.RemainingArguments,
                        projectContext.TargetFramework,
                        dotnetParams.Config)
                                   .ForwardStdErr()
                                   .ForwardStdOut()
                                   .Execute()
                                   .ExitCode;

                    Console.WriteLine($"Command returned {exitCode}");
                }
                catch (CommandUnknownException)
                {
                    Console.WriteLine($"Command not found");
                    return(1);
                }
            }
            return(0);
        }
예제 #10
0
        internal override int DoRunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams)
        {
            var commandFactory =
                new ProjectDependenciesCommandFactory(
                    projectContext.TargetFramework,
                    dotnetTestParams.Config,
                    dotnetTestParams.Output,
                    dotnetTestParams.BuildBasePath,
                    projectContext.ProjectDirectory);

            return(commandFactory.Create(
                       GetCommandName(projectContext.ProjectFile.TestRunner),
                       GetCommandArgs(projectContext, dotnetTestParams),
                       projectContext.TargetFramework,
                       dotnetTestParams.Config)
                   .Execute()
                   .ExitCode);
        }
예제 #11
0
        internal override int DoRunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams)
        {
            try
            {
                var commandFactory =
                    new ProjectDependenciesCommandFactory(
                        projectContext.TargetFramework,
                        dotnetTestParams.Config,
                        dotnetTestParams.Output,
                        dotnetTestParams.BuildBasePath,
                        projectContext.ProjectDirectory);

                return(commandFactory.Create(
                           GetCommandName(projectContext.ProjectFile.TestRunner),
                           GetCommandArgs(projectContext, dotnetTestParams),
                           projectContext.TargetFramework,
                           dotnetTestParams.Config)
                       .ForwardStdErr()
                       .ForwardStdOut()
                       .Execute()
                       .ExitCode);
            }
            catch (CommandUnknownException e)
            {
                var commandFactory =
                    new DotNetCommandFactory();

                return(commandFactory.Create(
                           GetDotNetCommandName(projectContext.ProjectFile.TestRunner),
                           GetCommandArgs(projectContext, dotnetTestParams),
                           projectContext.TargetFramework,
                           dotnetTestParams.Config)
                       .ForwardStdErr()
                       .ForwardStdOut()
                       .Execute()
                       .ExitCode);
            }
        }
        public void It_resolves_tools_whose_package_name_is_different_than_dll_name()
        {
            var configuration = "Debug";

            var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "TestProjects"));
            var testInstance = testAssetManager.CreateTestInstance("AppWithDirectDependencyWithOutputName")
                .WithLockFiles();

            var buildCommand = new BuildCommand(
                Path.Combine(testInstance.TestRoot, "project.json"),
                configuration: configuration)
                    .ExecuteWithCapturedOutput()
                    .Should()
                    .Pass();

            var context = ProjectContext.Create(testInstance.TestRoot, FrameworkConstants.CommonFrameworks.NetCoreApp10);

            var factory = new ProjectDependenciesCommandFactory(
                FrameworkConstants.CommonFrameworks.NetCoreApp10,
                configuration,
                null,
                null,
                testInstance.TestRoot);

            var command = factory.Create("dotnet-tool-with-output-name", null);

            command.CommandArgs.Should().Contain(
                Path.Combine("ToolWithOutputName", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
        }