Ejemplo n.º 1
0
        public void DnuPack_ResourcesNoArgs_WarningAsErrorsCompilationOption(string flavor, string os, string architecture)
        {
            string stdOut;
            string stdError;
            var    runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);
            int    exitCode;

            using (var testEnv = new DnuTestEnvironment(runtimeHomeDir))
            {
                using (var tempDir = new DisposableDir())
                {
                    var appPath = Path.Combine(tempDir, "ResourcesTestProjects", "ReadFromResources");
                    TestUtils.CopyFolder(Path.Combine(TestUtils.GetMiscProjectsFolder(), "ResourcesTestProjects", "ReadFromResources"), appPath);
                    var workingDir = Path.Combine(appPath, "src", "ResourcesLibrary");

                    var environment = new Dictionary <string, string> {
                        { "DNX_TRACE", "0" }
                    };
                    DnuTestUtils.ExecDnu(
                        runtimeHomeDir,
                        "restore", "",
                        out stdOut,
                        out stdError,
                        environment: null,
                        workingDir: workingDir);
                    exitCode = DnuTestUtils.ExecDnu(
                        runtimeHomeDir,
                        "pack",
                        "",
                        out stdOut,
                        out stdError,
                        environment,
                        workingDir);

                    Assert.Empty(stdError);
                    Assert.Equal(0, exitCode);
                    Assert.True(Directory.Exists(Path.Combine(workingDir, "bin")));
                    Assert.True(File.Exists(Path.Combine(workingDir, "bin", "Debug", "dnx451", "fr-FR", "ResourcesLibrary.resources.dll")));
                    Assert.True(File.Exists(Path.Combine(workingDir, "bin", "Debug", "dnxcore50", "fr-FR", "ResourcesLibrary.resources.dll")));
                }
            }
        }
Ejemplo n.º 2
0
        public static DisposableDir PrepareTemporarySamplesFolder(string runtimeHomeDir)
        {
            var tempDir = new DisposableDir();

            TestUtils.CopyFolder(TestUtils.GetSamplesFolder(), tempDir);

            // Make sure sample projects depend on runtime components from newly built dnx
            var currentDnxSolutionRootDir = ProjectRootResolver.ResolveRootDirectory(Directory.GetCurrentDirectory());
            var currentDnxSolutionSrcPath = Path.Combine(currentDnxSolutionRootDir, "src").Replace("\\", "\\\\");
            var samplesGlobalJson         = new JObject();

            samplesGlobalJson["projects"] = new JArray(new[] { currentDnxSolutionSrcPath });
            File.WriteAllText(Path.Combine(tempDir, GlobalSettings.GlobalFileName), samplesGlobalJson.ToString());

            // Make sure package restore can be successful
            const string nugetConfigName = "NuGet.config";

            File.Copy(Path.Combine(currentDnxSolutionRootDir, nugetConfigName), Path.Combine(tempDir, nugetConfigName));

            // Use the newly built runtime to generate lock files for samples
            string stdOut, stdErr;
            int    exitCode;

            foreach (var projectDir in Directory.EnumerateDirectories(tempDir))
            {
                exitCode = DnuTestUtils.ExecDnu(
                    runtimeHomeDir,
                    subcommand: "restore",
                    arguments: projectDir,
                    stdOut: out stdOut,
                    stdErr: out stdErr);

                if (exitCode != 0)
                {
                    Console.WriteLine(stdOut);
                    Console.WriteLine(stdErr);
                }
            }

            return(tempDir);
        }