From 43e18a190df6381b638b054c6e8291cf1c152407 Mon Sep 17 00:00:00 2001 From: Rama Krishnan Raghupathy Date: Thu, 25 May 2017 18:44:40 -0700 Subject: [PATCH] adding Store support to testfixture Commit migrated from https://github.com/dotnet/core-setup/commit/a5ac221ff6ebf6e8be292289f37946a5cbcaff72 --- src/installer/test/TestUtils/DotNetCli.cs | 2 + src/installer/test/TestUtils/TestProjectFixture.cs | 59 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/installer/test/TestUtils/DotNetCli.cs b/src/installer/test/TestUtils/DotNetCli.cs index 60b1828..48b4637 100644 --- a/src/installer/test/TestUtils/DotNetCli.cs +++ b/src/installer/test/TestUtils/DotNetCli.cs @@ -41,6 +41,8 @@ namespace Microsoft.DotNet.Cli.Build public Command Test(params string[] args) => Exec("test", args); public Command Publish(params string[] args) => Exec("publish", args); + public Command Store(params string[] args) => Exec("store", args); + private void ComputeSharedFxPaths() { var sharedFxBaseDirectory = Path.Combine(BinPath, "shared", "Microsoft.NETCore.App"); diff --git a/src/installer/test/TestUtils/TestProjectFixture.cs b/src/installer/test/TestUtils/TestProjectFixture.cs index e219fa9..8dd2dd2 100644 --- a/src/installer/test/TestUtils/TestProjectFixture.cs +++ b/src/installer/test/TestUtils/TestProjectFixture.cs @@ -235,6 +235,65 @@ namespace Microsoft.DotNet.CoreSetup.Test return this; } + public TestProjectFixture StoreProject( + DotNetCli dotnet = null, + string runtime = null, + string framework = "netcoreapp2.0", + string manifest = null, + string outputDirectory = null) + { + dotnet = dotnet ?? _sdkDotnet; + outputDirectory = outputDirectory ?? _testProject.OutputDirectory; + + var storeArgs = new List(); + storeArgs.Add("--runtime"); + if (runtime != null) + { + storeArgs.Add(runtime); + } + else + { + storeArgs.Add(CurrentRid); + } + + if (framework != null) + { + storeArgs.Add("--framework"); + storeArgs.Add(framework); + } + + storeArgs.Add("--manifest"); + if (manifest != null) + { + storeArgs.Add(manifest); + } + else + { + storeArgs.Add(_sourceTestProject.ProjectFile); + } + + if (outputDirectory != null) + { + storeArgs.Add("-o"); + storeArgs.Add(outputDirectory); + } + + storeArgs.Add("--working-dir"); + storeArgs.Add("store_workin_dir"); + + dotnet.Store(storeArgs.ToArray()) + .WorkingDirectory(_testProject.ProjectDirectory) + .Environment("NUGET_PACKAGES", _repoDirectoriesProvider.NugetPackages) + .CaptureStdErr() + .CaptureStdOut() + .Execute() + .EnsureSuccessful(); + + _testProject.LoadOutputFiles(); + + return this; + } + public TestProjectFixture PublishProject( DotNetCli dotnet = null, string runtime = null, -- 2.7.4