Exemplo 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>();

            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($"/p:MNAVersion={_repoDirectoriesProvider.MicrosoftNETCoreAppVersion}");

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

            _testProject.LoadOutputFiles();

            return(this);
        }
Exemplo n.º 2
0
        private static void CreateStubPackage(DotNetCli dotnet,
                                              string packageId,
                                              string version,
                                              string intermediateDirectory,
                                              string outputDirectory)
        {
            var projectJson = new StringBuilder();

            projectJson.Append("{");
            projectJson.Append($"  \"version\": \"{version}\",");
            projectJson.Append($"  \"name\": \"{packageId}\",");
            projectJson.Append("  \"packOptions\": { \"files\": { \"include\": \"dummy.txt\" } },");
            projectJson.Append("  \"frameworks\": { \"netcoreapp1.0\": { } },");
            projectJson.Append("}");

            var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate");
            var tempPjFile      = Path.Combine(tempPjDirectory, "project.json");

            File.WriteAllText(tempPjFile, projectJson.ToString());

            dotnet.Pack(
                tempPjFile, "--no-build",
                "--output", outputDirectory)
            .WorkingDirectory(tempPjDirectory)
            .Execute()
            .EnsureSuccessful();
        }
Exemplo n.º 3
0
        public SDKLookup()
        {
            // The dotnetSDKLookup dir will contain some folders and files that will be
            // necessary to perform the tests
            string baseDir = Path.Combine(TestArtifact.TestArtifactsPath, "dotnetSDKLookup");

            _baseDir = SharedFramework.CalculateUniqueTestDirectory(baseDir);

            // The three tested locations will be the cwd, the user folder and the exe dir. cwd and user are no longer supported.
            //     All dirs will be placed inside the base folder
            _currentWorkingDir = Path.Combine(_baseDir, "cwd");
            _userDir           = Path.Combine(_baseDir, "user");
            _executableDir     = Path.Combine(_baseDir, "exe");

            DotNet = new DotNetBuilder(_baseDir, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
                     .AddMicrosoftNETCoreAppFramework("9999.0.0")
                     .Build();

            RepoDirectories = new RepoDirectoriesProvider(builtDotnet: DotNet.BinPath);

            // SdkBaseDirs contain all available version folders
            _cwdSdkBaseDir  = Path.Combine(_currentWorkingDir, "sdk");
            _userSdkBaseDir = Path.Combine(_userDir, ".dotnet", RepoDirectories.BuildArchitecture, "sdk");
            _exeSdkBaseDir  = Path.Combine(_executableDir, "sdk");

            // Create directories
            Directory.CreateDirectory(_cwdSdkBaseDir);
            Directory.CreateDirectory(_userSdkBaseDir);
            Directory.CreateDirectory(_exeSdkBaseDir);

            // Trace messages used to identify from which folder the SDK was picked
            _exeSelectedMessage = $"Using dotnet SDK dll=[{_exeSdkBaseDir}";
        }
Exemplo n.º 4
0
            public SharedTestState()
            {
                DotNetWithOneFramework = DotNet("WithOneFramework")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.3")
                                         .Build();

                DotNetWithPreReleaseFramework = DotNet("WithPreReleaseFramework")
                                                .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.3-preview.2")
                                                .Build();

                DotNetWithManyVersions = DotNet("WithManyVersions")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("2.3.1-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("2.3.2")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.2")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.3-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.2.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.5.1-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.5.2")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.3-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.3-preview.2")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.4-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.2.3-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.2.3-preview.2")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.2-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.1.1-preview.1")
                                         .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.1.2-preview.1")
                                         .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();
            }
Exemplo n.º 5
0
            public SharedTestState()
            {
                DotNetMainHive = DotNet("MainHive")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.2.0")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.2")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.3")
                                 .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.1.2")
                                 .Build();

                DotNetGlobalHive = DotNet("GlobalHive")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.2")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.1.4")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.2.0")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.0.1")
                                   .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.1.2")
                                   .Build();

                DotNetCurrentHive = DotNet("CurrentHive")
                                    .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.0")
                                    .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("7.3.0")
                                    .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();

                _testOnlyProductBehaviorScope = TestOnlyProductBehavior.Enable(DotNetMainHive.GreatestVersionHostFxrFilePath);
            }
Exemplo n.º 6
0
 static async Task Main(string[] args)
 {
     DotNetCli.Init();
     DotNetCli.ContainerBuilder.RegisterType <SomeService>().As <ISomeService>();
     DotNetCli.RegisterHandler <Example>();
     await DotNetCli.RunAsync(args);
 }
            public SharedTestState()
            {
                DotNetWithNETCoreAppReleaseAndPreRelease = DotNet("DotNetWithNETCoreAppReleaseAndPreRelease")

                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.0-preview.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.0-preview.2")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.2-preview.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.2")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.1.3-preview.1")

                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.5.1-preview.2")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("4.5.2-preview.1")

                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.0-preview.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.2-preview.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.2")

                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.5.1-preview.2")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.5.2")

                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.0.1")
                                                           .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("6.0.2-preview.1")

                                                           .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();
            }
Exemplo n.º 8
0
            public SharedTestState()
            {
                // The dotnetSDKLookup dir will contain some folders and files that will be
                // necessary to perform the tests
                string baseDir = Path.Combine(TestArtifact.TestArtifactsPath, "dotnetSDKLookup");

                BaseDir          = SharedFramework.CalculateUniqueTestDirectory(baseDir);
                _baseDirArtifact = new TestArtifact(BaseDir);

                // The three tested locations will be the cwd and the exe dir. cwd is no longer supported.
                //     All dirs will be placed inside the base folder

                BuiltDotNet = new DotNetCli(Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"));

                RepoDirectories = new RepoDirectoriesProvider();

                // Executable location is created per test as each test adds a different set of SDK versions

                var currentWorkingSdk = new DotNetBuilder(BaseDir, BuiltDotNet.BinPath, "current")
                                        .AddMockSDK("10000.0.0", "9999.0.0")
                                        .Build();

                CurrentWorkingDir = currentWorkingSdk.BinPath;

                TestAssetsPath = Path.Combine(RepoDirectories.TestAssetsFolder, "TestUtils", "SDKLookup");
            }
Exemplo n.º 9
0
            public SdkResolutionFixture(SharedTestState state)
            {
                _builtDotnet = Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish");
                Dotnet       = new DotNetCli(_builtDotnet);

                _fixture = state.HostApiInvokerAppFixture.Copy();

                Directory.CreateDirectory(WorkingDir);

                // start with an empty global.json, it will be ignored, but prevent one lying on disk
                // on a given machine from impacting the test.
                File.WriteAllText(GlobalJson, "{}");

                foreach (string sdk in ProgramFilesGlobalSdks)
                {
                    Directory.CreateDirectory(Path.Combine(ProgramFilesGlobalSdkDir, sdk));
                }
                foreach (string sdk in SelfRegisteredGlobalSdks)
                {
                    Directory.CreateDirectory(Path.Combine(SelfRegisteredGlobalSdkDir, sdk));
                }
                foreach (string sdk in LocalSdks)
                {
                    Directory.CreateDirectory(Path.Combine(LocalSdkDir, sdk));
                }
            }
Exemplo n.º 10
0
            public SharedTestState()
            {
                copiedDotnet = Path.Combine(TestArtifact.TestArtifactsPath, "runtimeProperties");
                SharedFramework.CopyDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), copiedDotnet);

                MockSDK = new DotNetBuilder(copiedDotnet, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
                          .AddMicrosoftNETCoreAppFrameworkMockCoreClr("9999.0.0")
                          .AddMockSDK("9999.0.0-dev", "9999.0.0")
                          .Build();

                File.WriteAllText(Path.Combine(MockSDK.BinPath, "global.json"),
                                  @"
{
    ""sdk"": {
      ""version"": ""9999.0.0-dev""
    }
}");

                RepoDirectories = new RepoDirectoriesProvider(builtDotnet: copiedDotnet);

                RuntimePropertiesFixture = new TestProjectFixture("RuntimeProperties", RepoDirectories)
                                           .EnsureRestored()
                                           .BuildProject();

                RuntimeConfig.FromFile(RuntimePropertiesFixture.TestProject.RuntimeConfigJson)
                .WithProperty(AppTestPropertyName, AppTestPropertyValue)
                .Save();

                RuntimeConfig.FromFile(Path.Combine(RuntimePropertiesFixture.BuiltDotnet.GreatestVersionSharedFxPath, "Microsoft.NETCore.App.runtimeconfig.json"))
                .WithProperty(FrameworkTestPropertyName, FrameworkTestPropertyValue)
                .Save();
            }
Exemplo n.º 11
0
        public TestProjectFixture(TestProjectFixture fixtureToCopy)
        {
            _testProjectName            = fixtureToCopy._testProjectName;
            _exeExtension               = fixtureToCopy._exeExtension;
            _sharedLibraryExtension     = fixtureToCopy._sharedLibraryExtension;
            _sharedLibraryPrefix        = fixtureToCopy._sharedLibraryPrefix;
            _repoDirectoriesProvider    = fixtureToCopy._repoDirectoriesProvider;
            _testProjectSourceDirectory = fixtureToCopy._testProjectSourceDirectory;
            _testArtifactDirectory      = fixtureToCopy._testArtifactDirectory;
            _sdkDotnet         = fixtureToCopy._sdkDotnet;
            _currentRid        = fixtureToCopy._currentRid;
            _builtDotnet       = fixtureToCopy._builtDotnet;
            _sourceTestProject = fixtureToCopy._sourceTestProject;
            _framework         = fixtureToCopy._framework;
            _assemblyName      = fixtureToCopy._assemblyName;

            _testProject = CopyTestProject(
                fixtureToCopy.TestProject,
                _testArtifactDirectory,
                _exeExtension,
                _sharedLibraryExtension,
                _sharedLibraryPrefix,
                _assemblyName);

            fixtureToCopy._copiedTestProjects.Add(_testProject);
        }
Exemplo n.º 12
0
        public TestProjectFixture(
            string testProjectName,
            RepoDirectoriesProvider repoDirectoriesProvider,
            string framework    = null,
            string assemblyName = null)
        {
            ValidateRequiredDirectories(repoDirectoriesProvider);

            RepoDirProvider = repoDirectoriesProvider;

            Framework = framework ?? RepoDirProvider.GetTestContextVariable("MNA_TFM");

            SdkDotnet  = new DotNetCli(repoDirectoriesProvider.DotnetSDK);
            CurrentRid = repoDirectoriesProvider.TargetRID;

            BuiltDotnet = new DotNetCli(repoDirectoriesProvider.BuiltDotnet);

            _assemblyName = assemblyName;

            var sourceTestProjectPath = Path.Combine(repoDirectoriesProvider.TestAssetsFolder, "TestProjects", testProjectName);

            _sourceTestProject = new TestProject(
                sourceTestProjectPath,
                assemblyName: _assemblyName);

            TestProject = CopyTestProject(_sourceTestProject);
        }
Exemplo n.º 13
0
        protected override bool PrepareToConnect()
        {
            // The project must be built before we can test.
            var arguments = "build";

            // If this is .NET CLI version 2.0.0 or greater, we also specify --no-restore to ensure that
            // implicit restore on build doesn't slow the build down.
            if (DotNetCliVersion >= new SemanticVersion(2, 0, 0))
            {
                arguments += " --no-restore";
            }

            var process = DotNetCli.Start(arguments, WorkingDirectory);

            process.OutputDataReceived += (_, e) =>
            {
                EmitTestMessage(TestMessageLevel.Informational, e.Data ?? string.Empty);
            };

            process.ErrorDataReceived += (_, e) =>
            {
                EmitTestMessage(TestMessageLevel.Error, e.Data ?? string.Empty);
            };

            process.BeginOutputReadLine();
            process.BeginErrorReadLine();

            process.WaitForExit();

            return(process.ExitCode == 0 &&
                   File.Exists(Project.OutputFilePath));
        }
Exemplo n.º 14
0
        public TestProjectFixture PublishProject(
            DotNetCli dotnet       = null,
            string runtime         = null,
            string framework       = null,
            string selfContained   = null,
            string outputDirectory = null)
        {
            dotnet                      = dotnet ?? SdkDotnet;
            outputDirectory             = outputDirectory ?? TestProject.OutputDirectory;
            TestProject.OutputDirectory = outputDirectory;
            framework                   = framework ?? Framework;
            Framework                   = framework;

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

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

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

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

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

            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);
        }
Exemplo n.º 15
0
        public MockCoreClrSanity()
        {
            _dotnetDir = Path.Combine(TestArtifact.TestArtifactsPath, "mockCoreclrSanity");

            DotNet = new DotNetBuilder(_dotnetDir, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe")
                     .AddMicrosoftNETCoreAppFrameworkMockCoreClr("9999.0.0")
                     .Build();
        }
Exemplo n.º 16
0
        public void EnvironmentVariable_DotNetInfo_ListEnvironment()
        {
            var dotnet = new DotNetCli(sharedTestState.RepoDirectories.BuiltDotnet);

            var command = dotnet.Exec("--info")
                          .CaptureStdOut();

            var envVars = new (string Architecture, string Path)[] {
            public SharedTestState() : base()
            {
                DotNetWithNetCoreApp = DotNet("WithNetCoreApp")
                                       .AddMicrosoftNETCoreAppFrameworkMockCoreClr("4.0.0")
                                       .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp(MicrosoftNETCoreApp, "4.0.0");
            }
            public SharedTestState()
            {
                DotNetWithFrameworks = DotNet("WithOneFramework")
                                       .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("5.1.3")
                                       .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();
            }
Exemplo n.º 19
0
 private CommandResult RunTheApp(string path, DotNetCli dotnet)
 {
     return(Command.Create(path)
            .EnableTracingAndCaptureOutputs()
            .DotNetRoot(dotnet.BinPath)
            .MultilevelLookup(false)
            .Execute());
 }
Exemplo n.º 20
0
        public TestProjectFixture BuildProject(
            DotNetCli dotnet       = null,
            string runtime         = null,
            string framework       = null,
            string outputDirectory = null,
            bool restore           = false)
        {
            dotnet                      = dotnet ?? SdkDotnet;
            outputDirectory             = outputDirectory ?? TestProject.OutputDirectory;
            TestProject.OutputDirectory = outputDirectory;
            framework                   = framework ?? Framework;
            Framework                   = framework;

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

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

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

            if (framework != null)
            {
                buildArgs.Add("--framework");
                buildArgs.Add(framework);
            }

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

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

            dotnet.Build(buildArgs.ToArray())
            .WorkingDirectory(TestProject.ProjectDirectory)
            .Environment("NUGET_PACKAGES", RepoDirProvider.NugetPackages)
            .Environment("VERSION", "")     // Generate with package version 1.0.0, not %VERSION%
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .EnsureSuccessful();

            TestProject.LoadOutputFiles();

            return(this);
        }
Exemplo n.º 21
0
            public DotNetCliCustomizer(DotNetCli dotnet)
            {
                _dotnet     = dotnet;
                _basePath   = Path.GetFullPath(dotnet.BinPath);
                _backupPath = Path.Combine(_basePath, ".test.backup");

                if (Directory.Exists(_backupPath))
                {
                    throw new Exception($"The backup directory already exists. Please make sure that all customizers are correctly disposed.");
                }
            }
Exemplo n.º 22
0
            public SharedTestState()
            {
                RepoDirectories = new RepoDirectoriesProvider();
                BuiltDotNet     = new DotNetCli(RepoDirectories.BuiltDotnet);

                BaseDirectory = SharedFramework.CalculateUniqueTestDirectory(Path.Combine(TestArtifact.TestArtifactsPath, "argValidation"));

                // Create an empty global.json file
                Directory.CreateDirectory(BaseDirectory);
                File.WriteAllText(Path.Combine(BaseDirectory, "global.json"), "{}");
            }
Exemplo n.º 23
0
 private void RunTest(
     DotNetCli dotNet,
     Func <RuntimeConfig, RuntimeConfig> runtimeConfig,
     Action <CommandResult> resultAction)
 {
     RunTest(
         dotNet,
         SharedState.FrameworkReferenceApp,
         runtimeConfig,
         resultAction);
 }
Exemplo n.º 24
0
            public SharedTestState()
            {
                DotNetWithFrameworks = DotNet("WithOneFramework")
                                       .AddMicrosoftNETCoreAppFramework("5.1.3")
                                       .AddFramework(
                    MiddleWare, "2.1.2",
                    runtimeConfig => runtimeConfig.WithFramework(MicrosoftNETCoreApp, "5.1.3"))
                                       .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();
            }
Exemplo n.º 25
0
            public SharedTestState()
            {
                DotNetWithNETCoreAppRelease = DotNet("DotNetWithNETCoreAppRelease")
                                              .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("2.1.2")
                                              .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("2.1.3")
                                              .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("2.4.0")
                                              .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("2.4.1")
                                              .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("3.1.1")
                                              .AddMicrosoftNETCoreAppFrameworkMockHostPolicy("3.1.2")
                                              .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();
            }
Exemplo n.º 26
0
            public SharedTestState()
            {
                DotNetMainHive = DotNet("MainHive")
                                 .AddMicrosoftNETCoreAppFramework("5.2.0")
                                 .AddMicrosoftNETCoreAppFramework("6.1.2")
                                 .Build();

                DotNetGlobalHive = DotNet("GlobalHive")
                                   .AddMicrosoftNETCoreAppFramework("5.1.2")
                                   .AddMicrosoftNETCoreAppFramework("6.2.0")
                                   .Build();

                FrameworkReferenceApp = CreateFrameworkReferenceApp();
            }
Exemplo n.º 27
0
        public TestProjectFixture(
            string testProjectName,
            RepoDirectoriesProvider repoDirectoriesProvider,
            string exeExtension               = null,
            string sharedLibraryExtension     = null,
            string sharedLibraryPrefix        = null,
            string testProjectSourceDirectory = null,
            string testArtifactDirectory      = null,
            string dotnetInstallPath          = null,
            string currentRid            = null,
            string builtDotnetOutputPath = null,
            string framework             = null,
            string assemblyName          = null)
        {
            ValidateRequiredDirectories(repoDirectoriesProvider);

            _testProjectName = testProjectName;
            _framework       = framework ?? Environment.GetEnvironmentVariable("MNA_TFM");

            _exeExtension           = exeExtension ?? RuntimeInformationExtensions.GetExeExtensionForCurrentOSPlatform();
            _sharedLibraryExtension = sharedLibraryExtension
                                      ?? RuntimeInformationExtensions.GetSharedLibraryExtensionForCurrentPlatform();
            _sharedLibraryPrefix = sharedLibraryPrefix
                                   ?? RuntimeInformationExtensions.GetSharedLibraryPrefixForCurrentPlatform();

            _repoDirectoriesProvider = repoDirectoriesProvider;

            _testProjectSourceDirectory = testProjectSourceDirectory
                                          ?? Path.Combine(repoDirectoriesProvider.RepoRoot, "src", "test", "Assets", "TestProjects");
            _testArtifactDirectory = _testArtifactDirectory
                                     ?? Environment.GetEnvironmentVariable(s_testArtifactDirectoryEnvironmentVariable)
                                     ?? Path.Combine(AppContext.BaseDirectory, s_testArtifactDirectoryEnvironmentVariable);

            _sdkDotnet  = new DotNetCli(dotnetInstallPath ?? repoDirectoriesProvider.DotnetSDK);
            _currentRid = currentRid ?? repoDirectoriesProvider.TargetRID;

            _builtDotnet = new DotNetCli(repoDirectoriesProvider.BuiltDotnet);

            _assemblyName = assemblyName;

            InitializeTestProject(
                _testProjectName,
                _testProjectSourceDirectory,
                _testArtifactDirectory,
                _exeExtension,
                _sharedLibraryExtension,
                _sharedLibraryPrefix,
                _assemblyName);
        }
Exemplo n.º 28
0
        public TestProjectFixture PublishProject(
            DotNetCli dotnet       = null,
            string runtime         = null,
            string framework       = null,
            string outputDirectory = null)
        {
            dotnet          = dotnet ?? _sdkDotnet;
            outputDirectory = outputDirectory ?? _testProject.OutputDirectory;
            _testProject.OutputDirectory = outputDirectory;
            framework  = framework ?? _framework;
            _framework = framework;

            var publishArgs = new List <string>();

            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:NETCoreAppFramework={framework}");
            }

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

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

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

            _testProject.LoadOutputFiles();

            return(this);
        }
Exemplo n.º 29
0
        private void CreateDummyFile(DotNetCli dotnet, string intermediateDirectory)
        {
            var dummyTxt = "dummy text";

            var tempPjDirectory = Path.Combine(intermediateDirectory, "dummyNuGetPackageIntermediate");

            FS.Rmdir(tempPjDirectory);

            Directory.CreateDirectory(tempPjDirectory);

            var dummyTextFile = Path.Combine(tempPjDirectory, "dummy.txt");

            File.WriteAllText(dummyTextFile, dummyTxt);

            _dummyFileCreated = true;
        }
Exemplo n.º 30
0
        public TestProjectFixture BuildProject(
            DotNetCli dotnet       = null,
            string runtime         = null,
            string framework       = null,
            string outputDirectory = null)
        {
            dotnet          = dotnet ?? _sdkDotnet;
            outputDirectory = outputDirectory ?? _testProject.OutputDirectory;
            _testProject.OutputDirectory = outputDirectory;
            framework  = framework ?? _framework;
            _framework = framework;

            var buildArgs = new List <string>();

            buildArgs.Add("--no-restore");

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

            if (framework != null)
            {
                buildArgs.Add("--framework");
                buildArgs.Add(framework);
            }

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

            dotnet.Build(buildArgs.ToArray())
            .WorkingDirectory(_testProject.ProjectDirectory)
            .Environment("NUGET_PACKAGES", _repoDirectoriesProvider.NugetPackages)
            .Environment("VERSION", "")     // Generate with package version 1.0.0, not %VERSION%
            .CaptureStdErr()
            .CaptureStdOut()
            .Execute()
            .EnsureSuccessful();

            _testProject.LoadOutputFiles();

            return(this);
        }