Ejemplo n.º 1
0
        protected override SdkCommandSpec CreateCommand(params string[] args)
        {
            var newArgs = new List <string>();

            newArgs.Add("restore");

            if (_sources.Any())
            {
                newArgs.Add("-Source");
                newArgs.Add(string.Join(";", _sources));
            }

            newArgs.Add(FullPathProjectFile);

            newArgs.AddRange(args);

            if (string.IsNullOrEmpty(TestContext.Current.NuGetExePath))
            {
                throw new InvalidOperationException("Path to nuget.exe not set");
            }

            var ret = new SdkCommandSpec()
            {
                FileName  = TestContext.Current.NuGetExePath,
                Arguments = newArgs
            };

            return(ret);
        }
Ejemplo n.º 2
0
        protected override SdkCommandSpec CreateCommand(IEnumerable <string> args)
        {
            var newArgs = new List <string>();

            newArgs.Add("restore");

            newArgs.Add(FullPathProjectFile);

            newArgs.Add("-PackagesDirectory");
            newArgs.Add(PackagesDirectory ?? TestContext.Current.NuGetCachePath);

            newArgs.AddRange(args);

            if (string.IsNullOrEmpty(TestContext.Current.NuGetExePath))
            {
                throw new InvalidOperationException("Path to nuget.exe not set");
            }

            var nugetExePath = TestContext.Current.NuGetExePath;

            if (!string.IsNullOrEmpty(NuGetExeVersion))
            {
                nugetExePath = Path.Combine(Path.GetDirectoryName(nugetExePath), NuGetExeVersion, "nuget.exe");
            }

            if (!File.Exists(nugetExePath))
            {
                string directory = Path.GetDirectoryName(nugetExePath);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                string url = string.IsNullOrEmpty(NuGetExeVersion) ?
                             "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" :
                             $"https://dist.nuget.org/win-x86-commandline/v{NuGetExeVersion}/nuget.exe";

                using (var client = new System.Net.Http.HttpClient())
                    using (var response = client.GetAsync(url).ConfigureAwait(false).GetAwaiter().GetResult())
                        using (var fs = new FileStream(nugetExePath, FileMode.CreateNew))
                        {
                            response.Content.CopyToAsync(fs).ConfigureAwait(false).GetAwaiter().GetResult();
                        }
            }

            var ret = new SdkCommandSpec()
            {
                FileName  = nugetExePath,
                Arguments = newArgs
            };

            TestContext.Current.AddTestEnvironmentVariables(ret);

            return(ret);
        }
Ejemplo n.º 3
0
        protected override SdkCommandSpec CreateCommand(IEnumerable <string> args)
        {
            var sdkCommandSpec = new SdkCommandSpec()
            {
                FileName         = "dotnet",
                Arguments        = args.ToList(),
                WorkingDirectory = WorkingDirectory
            };

            return(sdkCommandSpec);
        }
Ejemplo n.º 4
0
        protected override SdkCommandSpec CreateCommand(string[] args)
        {
            var sdkCommandSpec = new SdkCommandSpec()
            {
                FileName         = _commandPath,
                Arguments        = args.ToList(),
                WorkingDirectory = WorkingDirectory,
            };

            TestContext.Current.AddTestEnvironmentVariables(sdkCommandSpec);
            return(sdkCommandSpec);
        }
Ejemplo n.º 5
0
        protected override SdkCommandSpec CreateCommand(IEnumerable <string> args)
        {
            var sdkCommandSpec = new SdkCommandSpec()
            {
                FileName         = TestContext.Current.ToolsetUnderTest.DotNetHostPath,
                Arguments        = args.ToList(),
                WorkingDirectory = WorkingDirectory
            };

            TestContext.Current.AddTestEnvironmentVariables(sdkCommandSpec);
            return(sdkCommandSpec);
        }
Ejemplo n.º 6
0
        protected override SdkCommandSpec CreateCommand(IEnumerable <string> args)
        {
            var sdkCommandSpec = new SdkCommandSpec()
            {
                FileName         = "dotnet",
                Arguments        = args.ToList(),
                WorkingDirectory = WorkingDirectory
            };

            if (!_environment.ContainsKey(Helpers.HomeEnvironmentVariableName))
            {
                throw new Exception($"{nameof(Helpers.HomeEnvironmentVariableName)} is not set, call {nameof(DotnetNewCommand)}{nameof(WithEnvironmentVariable)} to set it.");
            }
            return(sdkCommandSpec);
        }
Ejemplo n.º 7
0
        protected override SdkCommandSpec CreateCommand(IEnumerable <string> args)
        {
            var newArgs = new List <string>();

            newArgs.Add("restore");

            if (_sources.Any())
            {
                newArgs.Add("-Source");
                newArgs.Add(string.Join(";", _sources));
            }

            newArgs.Add(FullPathProjectFile);

            newArgs.Add("-PackagesDirectory");
            newArgs.Add(TestContext.Current.NuGetCachePath);

            newArgs.AddRange(args);

            if (string.IsNullOrEmpty(TestContext.Current.NuGetExePath))
            {
                throw new InvalidOperationException("Path to nuget.exe not set");
            }
            else if (!File.Exists(TestContext.Current.NuGetExePath))
            {
                //  https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
                using (var client = new System.Net.Http.HttpClient())
                    using (var response = client.GetAsync("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe").ConfigureAwait(false).GetAwaiter().GetResult())
                        using (var fs = new FileStream(TestContext.Current.NuGetExePath, FileMode.CreateNew))
                        {
                            response.Content.CopyToAsync(fs).ConfigureAwait(false).GetAwaiter().GetResult();
                        }
            }

            var ret = new SdkCommandSpec()
            {
                FileName  = TestContext.Current.NuGetExePath,
                Arguments = newArgs
            };

            return(ret);
        }
Ejemplo n.º 8
0
        protected override SdkCommandSpec CreateCommand(params string[] args)
        {
            var newArgs = new List <string>();

            newArgs.Add("restore");

            if (_sources.Any())
            {
                newArgs.Add("-Source");
                newArgs.Add(string.Join(";", _sources));
            }

            newArgs.Add(FullPathProjectFile);

            newArgs.Add("-PackagesDirectory");
            newArgs.Add(TestContext.Current.NuGetCachePath);

            newArgs.AddRange(args);

            if (string.IsNullOrEmpty(TestContext.Current.NuGetExePath))
            {
                throw new InvalidOperationException("Path to nuget.exe not set");
            }
            else if (!File.Exists(TestContext.Current.NuGetExePath))
            {
                //  https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
                var client = new System.Net.WebClient();
                client.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", TestContext.Current.NuGetExePath);
            }

            var ret = new SdkCommandSpec()
            {
                FileName  = TestContext.Current.NuGetExePath,
                Arguments = newArgs
            };

            return(ret);
        }