Beispiel #1
0
        public void TemplateRestoresAndBuildsWithoutWarnings(
            string language,
            string projectType,
            bool useNuGetConfigForAspNet,
            bool skipSpaWebpackSteps)
        {
            string rootPath           = TestAssets.CreateTestDirectory(identifier: $"{language}_{projectType}").FullName;
            string noRestoreDirective = "--no-restore";

            new TestCommand("dotnet")
            {
                WorkingDirectory = rootPath
            }
            .Execute($"new {projectType} -lang {language} -o {rootPath} --debug:ephemeral-hive {noRestoreDirective}")
            .Should().Pass();

            if (useNuGetConfigForAspNet)
            {
                AspNetNuGetConfiguration.WriteNuGetConfigWithAspNetPrivateFeeds(Path.Combine(rootPath, "NuGet.Config"));
            }

            if (skipSpaWebpackSteps)
            {
                // Not all CI machines have Node installed, so the build would fail if we tried
                // to run Webpack. Bypass this by making it appear that Webpack already ran.
                Directory.CreateDirectory(Path.Combine(rootPath, "wwwroot", "dist"));
                Directory.CreateDirectory(Path.Combine(rootPath, "ClientApp", "node_modules"));
                Directory.CreateDirectory(Path.Combine(rootPath, "node_modules"));
            }

            new TestCommand("dotnet")
            .WithWorkingDirectory(rootPath)
            .Execute($"restore")
            .Should().Pass();

            var buildResult = new TestCommand("dotnet")
                              .WithWorkingDirectory(rootPath)
                              .ExecuteWithCapturedOutput("build --no-restore")
                              .Should().Pass()
                              .And.NotHaveStdErr();
        }
Beispiel #2
0
        public void RestoreDoesNotUseAnyCliProducedPackagesOnItsTemplates()
        {
            string[] cSharpTemplates = new[] { "console", "classlib", "mstest", "xunit", "web", "mvc", "webapi" };

            var rootPath          = TestAssets.CreateTestDirectory().FullName;
            var packagesDirectory = Path.Combine(rootPath, "packages");

            // For testing the 2.1 templates - some of their packages are currently only in private feeds.
            var configFile = Path.Combine(rootPath, "NuGet.Config");

            AspNetNuGetConfiguration.WriteNuGetConfigWithAspNetPrivateFeeds(configFile);
            // For "normal" builds, once the packages needed for 2.1 templates are in the public feeds
            //var configFile = Path.Combine(RepoDirectoriesProvider.RepoRoot, "NuGet.Config");

            foreach (string cSharpTemplate in cSharpTemplates)
            {
                var projectFolder = Path.Combine(rootPath, cSharpTemplate + "1");
                Directory.CreateDirectory(projectFolder);
                CreateAndRestoreNewProject(cSharpTemplate, projectFolder, packagesDirectory, configFile);
            }

            Directory.EnumerateFiles(packagesDirectory, $"*.nupkg", SearchOption.AllDirectories)
            .Should().NotContain(p => p.Contains("Microsoft.DotNet.Cli.Utils"));
        }