Ejemplo n.º 1
0
        public TestProjectFixture StoreProject(
            DotNetCli dotnet       = null,
            string runtime         = null,
            string framework       = null,
            string manifest        = null,
            string outputDirectory = null)
        {
            dotnet          = dotnet ?? SdkDotnet;
            outputDirectory = outputDirectory ?? TestProject.OutputDirectory;
            framework       = framework ?? Framework;
            Framework       = framework;

            var storeArgs = new List <string>
            {
                "--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($"/p:MNAVersion={RepoDirProvider.MicrosoftNETCoreAppVersion}");
            storeArgs.Add($"/p:NETCoreAppFramework={Framework}");

            // Ensure the project's OutputType isn't 'Exe', since that causes issues with 'dotnet store'
            storeArgs.Add("/p:OutputType=Library");

            dotnet.Store(storeArgs.ToArray())
            .WorkingDirectory(TestProject.ProjectDirectory)
            .Environment("NUGET_PACKAGES", RepoDirProvider.NugetPackages)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .EnsureSuccessful();

            TestProject.LoadOutputFiles();

            return(this);
        }
Ejemplo n.º 2
0
 private TestProject CopyTestProject(TestProject sourceTestProject)
 {
     EnsureDirectoryBuildProps(TestArtifact.TestArtifactsPath);
     return(sourceTestProject.Copy());
 }
Ejemplo n.º 3
0
        public TestProjectFixture PublishProject(
            DotNetCli dotnet       = null,
            string runtime         = null,
            string framework       = null,
            string selfContained   = null,
            string outputDirectory = null,
            bool singleFile        = false,
            bool restore           = false)
        {
            dotnet                      = dotnet ?? SdkDotnet;
            outputDirectory             = outputDirectory ?? TestProject.OutputDirectory;
            TestProject.OutputDirectory = outputDirectory;
            framework                   = framework ?? Framework;
            Framework                   = framework;

            var publishArgs = new List <string>
            {
                "/bl:PublishProject.binlog"
            };

            if (restore != true)
            {
                publishArgs.Add("--no-restore");
            }

            if (runtime != null)
            {
                publishArgs.Add("--runtime");
                publishArgs.Add(runtime);
            }

            if (framework != null)
            {
                publishArgs.Add("--framework");
                publishArgs.Add(framework);
                publishArgs.Add($"/p:NetCoreAppCurrent={framework}");
            }

            if (selfContained != null)
            {
                publishArgs.Add("--self-contained");
                publishArgs.Add(selfContained);
            }

            if (outputDirectory != null)
            {
                publishArgs.Add("-o");
                publishArgs.Add(outputDirectory);
            }

            if (singleFile)
            {
                publishArgs.Add("/p:PublishSingleFile=true");
            }

            publishArgs.Add($"/p:TestTargetRid={RepoDirProvider.TargetRID}");
            publishArgs.Add($"/p:MNAVersion={RepoDirProvider.MicrosoftNETCoreAppVersion}");

            dotnet.Publish(publishArgs.ToArray())
            .WorkingDirectory(TestProject.ProjectDirectory)
            .Environment("NUGET_PACKAGES", RepoDirProvider.NugetPackages)
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .EnsureSuccessful();

            TestProject.LoadOutputFiles();

            return(this);
        }