public void SavePackage(PackageProject Model, PackageVersion Version, [NotNull] string FileName, string RootDirectory) { string directoryName = Path.GetDirectoryName(FileName); if (directoryName != null) Directory.CreateDirectory(directoryName); _enpacker.Enpack(Model, Version, RootDirectory).Save(FileName); }
public string ReplacePathVariables(string Pattern, PackageProject Project, PackageVersion Version) { ComponentProjectTarget sampleTarget = Project.Components.First().Targets.First(); var replacements = new Dictionary<string, string> { { "{version-major}", Version.Major.ToString(CultureInfo.InvariantCulture) }, { "{version-minor}", Version.Minor.ToString(CultureInfo.InvariantCulture) }, { "{version-label}", Version.Label }, { "{release-date}", Version.ReleaseDate.ToString("yyyy.MM.dd") }, { "{version}", CombineVersion(Version) }, { "{cell}", _indexHelper.GetCellName(sampleTarget.Cell) }, { "{module}", _indexHelper.GetModuleName(sampleTarget.Cell, sampleTarget.Module) }, { "{modification}", _indexHelper.GetModificationName(sampleTarget.Cell, sampleTarget.Modification) }, }; var sb = new StringBuilder(Pattern); foreach (var replacement in replacements) { string value = replacement.Value == null ? string.Empty : Path.GetInvalidFileNameChars() .Aggregate(replacement.Value, (current, invalidChar) => current.Replace(invalidChar, ' ')); sb.Replace(replacement.Key, value); } return sb.ToString(); }
public void SavePackage(PackageProject PackageProject, PackageVersion PackageVersion, string ProjectRoot) { string defaultFileName = _variablesProcessor.ReplacePathVariables(_launchParameters.OutputFileName ?? "{cell} ver. {version}.sfp", PackageProject, PackageVersion); SaveFileRequest.Raise(new SaveFileInteractionContext(new SaveFileRequestArguments(_savingTool.FileExtension, new FileRequestArguments.FileTypeDescription( _savingTool.FileExtension, "Файл пакета прошивок")) { DefaultFileName = defaultFileName }), c => SavePackage(c.FileName, PackageProject, PackageVersion, ProjectRoot)); }
public void Run() { VerifyParameters(); // ReSharper disable PossibleInvalidOperationException var version = new PackageVersion(_launchParameters.VersionMajor.Value, _launchParameters.VersionMinor.Value, _launchParameters.VersionLabel, _launchParameters.ReleaseDate.Value); // ReSharper restore PossibleInvalidOperationException PackageProject project = _projectSerializer.Load(_launchParameters.ProjectFileName); string fileName = _variablesProcessor.ReplacePathVariables(_launchParameters.OutputFileName, project, version); _savingTool.SavePackage(project, version, fileName, _launchParameters.RootDirectory); _recentProjectsService.UpdateRecentProject(new RecentProject { FileName = _launchParameters.ProjectFileName, MajorVersion = version.Major, MinorVersion = version.Minor }); }
public FirmwarePackage Enpack(PackageProject Project, PackageVersion Version, string RootDirectory) { return new FirmwarePackage { Components = Project.Components .Select(componentProject => new FirmwareComponent( componentProject.Targets.Select( t => new ComponentTarget(t.Cell, t.Modification, t.Channel, t.Module)).ToList(), componentProject.FileMaps .SelectMany(fm => fm.EnumerateFiles(RootDirectory)) .Select(f => new FirmwareFile(f.Name, f.Content)) .ToList()) { BootloaderRequirement = new BootloaderRequirement(componentProject.BootloaderRequirement.BootloaderId, new VersionRequirements( componentProject.BootloaderRequirement.CompatibleVersion, componentProject.BootloaderRequirement.Version)) }) .ToList(), Information = new PackageInformation(new Version(Version.Major, Version.Minor), Version.Label, Version.ReleaseDate) }; }
private void SavePackage(string FileName, PackageProject PackageProject, PackageVersion PackageVersion, string ProjectRoot) { if (FileName == null) return; _savingTool.SavePackage(PackageProject, PackageVersion, FileName, ProjectRoot); }
private string CombineVersion(PackageVersion Version) { return String.Format(string.IsNullOrWhiteSpace(Version.Label) ? "{0}.{1}" : "{0}.{1} {2}", Version.Major, Version.Minor, Version.Label); }