Beispiel #1
0
        /// <summary>
        /// 执行发布 nupkg 包的命令
        /// </summary>
        /// <param name="nugetToolPath"></param>
        /// <param name="nupkgFile"></param>
        /// <param name="source"></param>
        /// <param name="apiKey"></param>
        /// <param name="skipDuplicate"></param>
        public void RunPublishNupkg(string nugetToolPath, string nupkgFile, string source, string apiKey = "",
                                    bool skipDuplicate = true)
        {
            var temp = ProcessCommand.ToArgumentPath(nupkgFile);

            ExecuteProcessCommand(nugetToolPath,
                                  $"push {temp} -Source {source} {(string.IsNullOrEmpty(apiKey) ? "" : $"-ApiKey {apiKey}")} {(skipDuplicate ? "-SkipDuplicate" : "")}");
Beispiel #2
0
        /// <summary>
        /// 还原 NuGet 库,如果执行失败会抛出异常
        /// </summary>
        /// <param name="slnPath"></param>
        /// <param name="msbuildPath"></param>
        public void Restore(FileInfo slnPath, string msbuildPath)
        {
            var command =
                $"restore {ProcessCommand.ToArgumentPath(slnPath.FullName)} -MSBuildPath {ProcessCommand.ToArgumentPath(msbuildPath)}";

            ExecuteProcessCommand(GetNugetFile(), command);
        }
Beispiel #3
0
        /// <summary>
        /// 执行 nuget restore [command] 这里的[command]为传入参数,默认值是 sln 文件
        /// </summary>
        /// <param name="command"></param>
        public (bool success, string output) Restore(string command = "")
        {
            if (string.IsNullOrEmpty(command))
            {
                command = ProcessCommand.ToArgumentPath(CompileConfiguration.SlnPath);
            }

            (bool success, string output) = ExecuteProcessCommand(GetNugetFile(), $"restore {command}");
            return(success, output);
        }
        protected (bool success, string output) ExecuteCommand(string exeName, string arguments,
                                                               string workingDirectory = "")
        {
            Logger.LogInformation($"执行命令 {exeName} {arguments}");
            (bool success, string output) = ProcessCommand.ExecuteCommand(exeName, arguments, workingDirectory);

            if (success)
            {
                Logger.LogInformation(output);
            }
            else
            {
                Logger.LogWarning(output);
            }

            return(success, output);
        }
Beispiel #5
0
        public IEnumerable <string> GetNotInstalledToolList(List <string> packageNameList)
        {
            // 先去掉重复的
            packageNameList = packageNameList.Distinct().ToList();

            var(success, output) = ProcessCommand.ExecuteCommand("dotnet", "tool list -g");

            // 假定都是成功的
            // 只需要尝试寻找字符串是否匹配就可以判断是否已经安装了

            foreach (var package in packageNameList
                     // 如果后面不加上一个空格,将可能没有安装的工具判断是安装
                     // 也就是如果此时的 dotnetCampus.Foo 没有安装,但是 dotnetCampus.Foo2 安装了,那么判断 dotnetCampus.Foo 是安装的
                     .Select(package => package + " "))
            {
                if (!output.Contains(package, StringComparison.OrdinalIgnoreCase))
                {
                    yield return(package);
                }
            }
        }
        /// <summary>
        /// 执行编译
        /// </summary>
        public void Build(MSBuildCommandOptions options)
        {
            var configuration = options.MSBuildConfiguration;
            var slnPath       = options.SlnPath;
            var msbuildPath   = options.MSBuildPath;

            var command = $"/m:{options.MaxCpuCount}";

            command += $" /p:configuration={(configuration == MSBuildConfiguration.Release ? "release" : "debug")}";

            if (options.ShouldRestore)
            {
                command += " -restore";
            }

            if (string.IsNullOrEmpty(slnPath))
            {
                slnPath = CompileConfiguration.SlnPath;
            }

            command += $" {ProcessCommand.ToArgumentPath(slnPath)}";

            Build(command, msbuildPath);
        }
 /// <summary>
 /// 运行单元测试文件,通过 vstest.console.exe 运行
 /// </summary>
 /// <param name="file"></param>
 public void RunVsTestFile(FileInfo file)
 {
     ProcessCommand.RunCommand(GetVsTest(), ProcessCommand.ToArgumentPath(file.FullName));
 }