public void CopyPackageFiles(NugetPackage package) { var packageDir = GetPackageDir(package); Log.Info("Начало копирования файлов пакета " + package.Name); foreach (var project in package.Projects) { var from = Path.Combine(_solutionPath, project.Name, "bin40", _buildType, project.Name); var to = Path.Combine(packageDir, "lib", "net40", project.Name); var from1 = Path.Combine(_solutionPath, project.Name, "bin", _buildType, project.Name); var to1 = Path.Combine(packageDir, "lib", "net45", project.Name); CopyFile(@from, to); CopyFile(@from1, to1); } }
private string PrepareNuspec(NugetPackage package) { var fileName = package.Name + ".nuspec"; var targetFileName = string.Format("{0}.{1}.nuspec", package.Name, _versionString); var from = Path.Combine(GetPackageDir(package), fileName); var to = GetRealNuspecPath(package, targetFileName); var log = new StringBuilder(); log.AppendLine("Подготовка метаданных") .AppendFormat("Файл {0} {1}найден", from, File.Exists(from) ? "" : "не") .AppendLine(); bool foundPlaceholder = false; using (var rdr = File.OpenText(from)) using (var writer = File.CreateText(to)) { var nuspec = rdr.ReadToEnd(); if (nuspec.Contains(VersionPlaceholder)) { foundPlaceholder = true; log.AppendLine("Найдено место для вставки версии"); nuspec = nuspec.Replace(VersionPlaceholder, _versionString); } else { log.AppendLine("Не найдено место вставки версии в файле " + from); } writer.Write(nuspec); } log.AppendLine("Записан файл реальной конфигурации " + targetFileName); if (!File.Exists(from) || !foundPlaceholder) { Log.Warn(log.ToString()); } else { Log.Info(log.ToString()); } return(to); }
private string GetRealNuspecPath(NugetPackage package, string targetFileName) { return(Path.Combine(GetPackageDir(package), targetFileName)); }
public void Pack(NugetPackage package) { Log.Info("Начало упаковки " + package.Name); var realNuspec = PrepareNuspec(package); var startInfo = new ProcessStartInfo(_nugetExe, "pack " + realNuspec) { WorkingDirectory = Path.GetDirectoryName(realNuspec), RedirectStandardOutput = true, UseShellExecute = false, }; var process = Process.Start(startInfo); //var process = Process.Start(_nugetExe, "pack " + realNuspec); if (process != null) { process.WaitForExit(); var sb = new StringBuilder("Запуск NuGet.exe pack для файла ").Append(realNuspec) .AppendLine() .AppendLine(process.StandardOutput.ReadToEnd()); if (process.ExitCode == 0) { Log.Info(sb.ToString()); } else { Log.Error(sb.ToString()); } } File.Delete(realNuspec); if (_publish) { Log.Info("Установка ключа публикации " + _publishKey); process = Process.Start(_nugetExe, "SetApiKey " + _publishKey); if (process != null) { process.WaitForExit(); } startInfo = new ProcessStartInfo(_nugetExe, "Push " + realNuspec.Replace(".nuspec", ".nupkg")) { WorkingDirectory = Path.GetDirectoryName(realNuspec), RedirectStandardOutput = true, UseShellExecute = false, }; process = Process.Start(startInfo); if (process != null) { process.WaitForExit(); var sb = new StringBuilder("Запуск публикации пакета") .Append(realNuspec) .AppendLine() .AppendLine(process.StandardOutput.ReadToEnd()); if (process.ExitCode == 0) { Log.Info(sb.ToString()); } else { Log.Error(sb.ToString()); } } } }
private string GetPackageDir(NugetPackage package) { return(Path.Combine(_solutionPath, "nuget", "Templates", package.Name)); }
private string GetRealNuspecPath(NugetPackage package, string targetFileName) { return Path.Combine(GetPackageDir(package), targetFileName); }
private string PrepareNuspec(NugetPackage package) { var fileName = package.Name + ".nuspec"; var targetFileName = string.Format("{0}.{1}.nuspec", package.Name, _versionString); var from = Path.Combine(GetPackageDir(package), fileName); var to = GetRealNuspecPath(package, targetFileName); var log = new StringBuilder(); log.AppendLine("Подготовка метаданных") .AppendFormat("Файл {0} {1}найден", from, File.Exists(from) ? "" : "не") .AppendLine(); bool foundPlaceholder = false; using (var rdr = File.OpenText(from)) using (var writer = File.CreateText(to)) { var nuspec = rdr.ReadToEnd(); if (nuspec.Contains(VersionPlaceholder)) { foundPlaceholder = true; log.AppendLine("Найдено место для вставки версии"); nuspec = nuspec.Replace(VersionPlaceholder, _versionString); } else { log.AppendLine("Не найдено место вставки версии в файле " + from); } writer.Write(nuspec); } log.AppendLine("Записан файл реальной конфигурации " + targetFileName); if (!File.Exists(from) || !foundPlaceholder) Log.Warn(log.ToString()); else Log.Info(log.ToString()); return to; }
public void Pack(NugetPackage package) { Log.Info("Начало упаковки " + package.Name); var realNuspec = PrepareNuspec(package); var startInfo = new ProcessStartInfo(_nugetExe, "pack " + realNuspec) { WorkingDirectory = Path.GetDirectoryName(realNuspec), RedirectStandardOutput = true, UseShellExecute = false, }; var process = Process.Start(startInfo); //var process = Process.Start(_nugetExe, "pack " + realNuspec); if (process != null) { process.WaitForExit(); var sb = new StringBuilder("Запуск NuGet.exe pack для файла ").Append(realNuspec) .AppendLine() .AppendLine(process.StandardOutput.ReadToEnd()); if(process.ExitCode==0) Log.Info(sb.ToString()); else Log.Error(sb.ToString()); } File.Delete(realNuspec); if (_publish) { Log.Info("Установка ключа публикации " + _publishKey); process = Process.Start(_nugetExe, "SetApiKey " + _publishKey); if (process != null) { process.WaitForExit(); } startInfo = new ProcessStartInfo(_nugetExe, "Push " + realNuspec.Replace(".nuspec",".nupkg")) { WorkingDirectory = Path.GetDirectoryName(realNuspec), RedirectStandardOutput = true, UseShellExecute = false, }; process = Process.Start(startInfo); if (process != null) { process.WaitForExit(); var sb = new StringBuilder("Запуск публикации пакета") .Append(realNuspec) .AppendLine() .AppendLine(process.StandardOutput.ReadToEnd()); if (process.ExitCode == 0) Log.Info(sb.ToString()); else Log.Error(sb.ToString()); } } }
private string GetPackageDir(NugetPackage package) { return Path.Combine(_solutionPath, "nuget", "Templates", package.Name); }
public void CopyPackageFiles(NugetPackage package) { var packageDir = GetPackageDir(package); Log.Info("Начало копирования файлов пакета "+package.Name); foreach (var project in package.Projects) { var from = Path.Combine(_solutionPath, project.Name, "bin40", _buildType, project.Name); var to = Path.Combine(packageDir, "lib","net40", project.Name); var from1 = Path.Combine(_solutionPath, project.Name, "bin", _buildType, project.Name); var to1 = Path.Combine(packageDir, "lib", "net45", project.Name); CopyFile(@from, to); CopyFile(@from1, to1); } }