/// <summary> /// called when the worker is supposed to start /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void DoWork(object sender, DoWorkEventArgs e) { Project activeProject = (Project)e.Argument; LoggingManager.Instance.Logger.Debug(string.Format("Project Fullname: {0}", activeProject.FullName)); //-----make sure the nuGet exe does exist if (string.IsNullOrEmpty(OptionsManager.Instance.Configuration.GeneralOptions.NuGetOptions.ExePath)) { throw new NoNuGetExecutableExceptions("nuget.exe not found in the configuration"); } PackageInformation packageInfo = null; ProjectInformation projectInformation = null; //----- prepare the project if (!_worker.CancellationPending) { _worker.ReportProgress(0, "Preparing Project..."); PreAnalyseProject(activeProject, out packageInfo, out projectInformation); } //-----analyse the project if (!_worker.CancellationPending) { _worker.ReportProgress(50, "Analysing Project..."); AnalyseProject(activeProject, packageInfo, projectInformation); } e.Cancel = _worker.CancellationPending; e.Result = packageInfo; }
/// <summary> /// determines the nuspec files to add from the project /// </summary> private void DetermineNuSpecFiles(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation, Xml.Settings.General.NuGet.Target nuGetTarget) { LoggingManager.Instance.Logger.Debug("determine nuspec files started"); //-----add the assembly file packageInfo.NuSpecPackage.Files = new List <Xml.NuGet.NuSpec.File>(); packageInfo.NuSpecPackage.Files.Add(new Xml.NuGet.NuSpec.File() { Source = Path.Combine(packageInfo.Build.BuildPath, packageInfo.OutputFileName), Target = string.Format(@"lib\{0}", nuGetTarget.Name) }); //-----add the pdb file only if the debug useage is used and the value is known if (packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugInfo.Useage != Enumerations.Useage.None) { string source = Path.Combine(packageInfo.Build.BuildPath, StringUtil.ReplaceLastOccurrence(packageInfo.OutputFileName, Resources.ExtensionDLL, Resources.ExtensionPDB)); Xml.NuGet.NuSpec.File pdbFile = new Xml.NuGet.NuSpec.File() { Source = source, Target = string.Format(@"lib\{0}", nuGetTarget.Name) }; packageInfo.Build.PdbFiles.Add(pdbFile); if (packageInfo.Build.DebugInfo == Resources.DebugInfoPdbOnly || packageInfo.Build.DebugInfo == Resources.DebugInfoFull) { packageInfo.NuSpecPackage.Files.Add(pdbFile); } } //HACK this is needed since VB does not implement the documentation file the way CS does it, need to find a work arround if (projectInformation.Identifier == Enumerations.ProjectIdentifier.CS) { //include documentation files if needed foreach (string documentationFileUrl in ExtensionUtil.GetFilenames(activeProject.ConfigurationManager.ActiveConfiguration, Definitions.Constants.DocumentaionOutputGroupCanonicalName)) { Xml.NuGet.NuSpec.File documentationFile = new Xml.NuGet.NuSpec.File() { Source = documentationFileUrl, Target = string.Format(@"lib\{0}", nuGetTarget.Name) }; if (packageInfo.Build.DocumentationFile == null) { packageInfo.Build.DocumentationFile = documentationFile; } packageInfo.NuSpecPackage.Files.Add(documentationFile); } } //-----get all the includeable item here if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Files.FileIncludes.Count > 0) { if (projectInformation.Identifier == Enumerations.ProjectIdentifier.CS || projectInformation.Identifier == Enumerations.ProjectIdentifier.VB) { AddNuSpecFilesCSharpVisualBasic(activeProject.ProjectItems, packageInfo, projectInformation); } } LoggingManager.Instance.Logger.Debug("determine nuspec files finished"); }
private IEnumerable <PackageInformation> Parse([NotNull] Site site, [NotNull] XElement root) { Debug.ArgumentNotNull(site, nameof(site)); Debug.ArgumentNotNull(root, nameof(root)); foreach (var element in root.Elements()) { if (!CanShow(element)) { continue; } var fileName = element.GetElementValue("filename"); var name = element.GetElementValue("name"); if (string.IsNullOrEmpty(name)) { name = Path.GetFileNameWithoutExtension(fileName) ?? "[Unknown package]"; } var packageInformation = new PackageInformation(site, name, element.GetElementValue("author"), element.GetElementValue("version"), element.GetElementValue("publisher"), element.GetElementValue("license"), element.GetElementValue("comment"), element.GetElementValue("readme")) { ServerFileName = fileName }; yield return(packageInformation); } }
private void LoadPackages([NotNull] Site site, [NotNull] List <PackageInformation> packages, [NotNull] string folder) { Debug.ArgumentNotNull(site, nameof(site)); Debug.ArgumentNotNull(packages, nameof(packages)); Debug.ArgumentNotNull(folder, nameof(folder)); foreach (var fileName in AppHost.Files.GetFiles(folder)) { if (string.Compare(Path.GetExtension(fileName), @".zip", StringComparison.InvariantCultureIgnoreCase) != 0) { continue; } try { var packageAnalyzer = new PackageAnalyzer(fileName); var package = new PackageInformation(site, packageAnalyzer); packages.Add(package); } catch (Exception ex) { AppHost.Output.LogException(ex); } } foreach (var subfolder in AppHost.Files.GetDirectories(folder)) { LoadPackages(site, packages, subfolder); } }
private void ConnectionManagerOnPackageSent(object sender, PackageInformation packageInformation) { _uploadData += packageInformation.Size; Application.Current.Dispatcher.BeginInvoke( new Action(() => { _brakingCollectionManager.AddItem(packageInformation); })); }
/// <summary> /// saves /// </summary> /// <param name="activeProject"></param> /// <returns></returns> private void SaveChangesAssembly(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation) { LoggingManager.Instance.Logger.Debug("save changes c++ started"); StringBuilder errorMessage = new StringBuilder(); if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Metadata.Id.Save) { if (!Utils.ExtensionUtil.SetPropertyValue <string>(activeProject.Properties, projectInformation.Id, packageInfo.NuSpecPackage.Metadata.Id)) { string message = string.Format("could not save back id: {1}", packageInfo.NuSpecPackage.Metadata.Id); errorMessage.Append(string.Format("{0}{1}", Environment.NewLine, message)); LoggingManager.Instance.Logger.Warn(message); } } //-----find the assemblInfo string assemblyName = string.Format("{0}{1}", projectInformation.AssemblyName, projectInformation.FileExtension); ProjectItem assembly = Utils.ExtensionUtil.GetItem(assemblyName, activeProject.ProjectItems); if (assembly == null) { throw new FileNotFoundException(string.Format("assembly: {0} could not be found", assemblyName)); } else { //-----change the assemblyInfo string assemblyFileFullname = Utils.ExtensionUtil.GetPropertyValue <string>(assembly.Properties, Resources.PropertyFullpath, null); LoggingManager.Instance.Logger.Debug(string.Format("changing assemblyInfo: {0}", assemblyFileFullname)); try { IOUtil.ReadAndWriteLinesStream(assemblyFileFullname, true, string.Format("{0}.tmp", assemblyFileFullname), true, AssemblyInfoReadCallback, packageInfo, projectInformation); } catch (Exception) { string message = "error while changing the assembly info"; errorMessage.Append(string.Format("{0}{1}", Environment.NewLine, message)); } //-----log LoggingManager.Instance.Logger.Debug(string.Format("new project id: {0}", packageInfo.NuSpecPackage.Metadata.Id)); LoggingManager.Instance.Logger.Debug(string.Format("new project version: {0}", packageInfo.NuSpecPackage.Metadata.Version)); LoggingManager.Instance.Logger.Debug(string.Format("new project title: {0}", packageInfo.NuSpecPackage.Metadata.Title)); LoggingManager.Instance.Logger.Debug(string.Format("new project authors: {0}", packageInfo.NuSpecPackage.Metadata.Authors)); LoggingManager.Instance.Logger.Debug(string.Format("new project description: {0}", packageInfo.NuSpecPackage.Metadata.Description)); LoggingManager.Instance.Logger.Debug(string.Format("new project language: {0}", packageInfo.NuSpecPackage.Metadata.Language)); LoggingManager.Instance.Logger.Debug(string.Format("new project copyright: {0}", packageInfo.NuSpecPackage.Metadata.Copyright)); } LoggingManager.Instance.Logger.Debug("save changes c++ project finished"); if (errorMessage.Length > 0) { errorMessage.Insert(0, "Could not save back the following values:"); throw new IOException(errorMessage.ToString()); } }
/// <summary> /// analyses the c#/visualbasic projects /// </summary> /// <param name="activeProject">the active project that is to be deployed</param> /// <param name="project">project configuration to use</param> /// <returns>null if all information was gathered, otherwise the error string</returns> private string AnalyseAssembly(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation, out string monikerValue) { LoggingManager.Instance.Logger.Debug("analyse assembly started"); //-----minimum info monikerValue = ExtensionUtil.GetPropertyValue <string>(activeProject.Properties, projectInformation.Moniker, null); packageInfo.OutputFileName = ExtensionUtil.GetPropertyValue <string>(activeProject.Properties, projectInformation.OutputFileName, null); if (!string.IsNullOrEmpty(packageInfo.OutputFileName) && !packageInfo.OutputFileName.EndsWith(Definitions.Constants.OutputFileExtension)) { packageInfo.OutputFileName = string.Format("{0}{1}", packageInfo.OutputFileName, Definitions.Constants.OutputFileExtension); } //-----nuspec info packageInfo.NuSpecPackage = new Xml.NuGet.NuSpec.Package() { Metadata = new Xml.NuGet.NuSpec.Metadata(), Files = new List <Xml.NuGet.NuSpec.File>() }; packageInfo.NuSpecPackage.Metadata.Id = ExtensionUtil.GetPropertyValue <string>(activeProject.Properties, projectInformation.Id, null); //-----find the assemblInfo string assemblyName = string.Format("{0}{1}", projectInformation.AssemblyName, projectInformation.FileExtension); ProjectItem assembly = ExtensionUtil.GetItem(assemblyName, activeProject.ProjectItems); if (assembly == null) { throw new FileNotFoundException(string.Format("assembly: {0} could not be found", assemblyName)); } //-----read the assemblyInfo string assemblyFileFullname = ExtensionUtil.GetPropertyValue <string>(assembly.Properties, Resources.PropertyFullpath, null); LoggingManager.Instance.Logger.Debug(string.Format("reading assemblyInfo: {0}", assemblyFileFullname)); try { IOUtil.ReadLinesStream(assemblyFileFullname, AssemblyInfoReadCallback, packageInfo, projectInformation); } catch (Exception ex) { throw new IOException("could not read assemblyinfo", ex); } //-----log LoggingManager.Instance.Logger.Debug(string.Format("project moniker: {0}", monikerValue)); LoggingManager.Instance.Logger.Debug(string.Format("project output filename: {0}", packageInfo.OutputFileName)); LoggingManager.Instance.Logger.Debug(string.Format("project id: {0}", packageInfo.NuSpecPackage.Metadata.Id)); LoggingManager.Instance.Logger.Debug(string.Format("project version: {0}", packageInfo.NuSpecPackage.Metadata.Version)); LoggingManager.Instance.Logger.Debug(string.Format("project title: {0}", packageInfo.NuSpecPackage.Metadata.Title)); LoggingManager.Instance.Logger.Debug(string.Format("project authors: {0}", packageInfo.NuSpecPackage.Metadata.Authors)); LoggingManager.Instance.Logger.Debug(string.Format("project description: {0}", packageInfo.NuSpecPackage.Metadata.Description)); LoggingManager.Instance.Logger.Debug(string.Format("project language: {0}", packageInfo.NuSpecPackage.Metadata.Language)); LoggingManager.Instance.Logger.Debug(string.Format("project copyright: {0}", packageInfo.NuSpecPackage.Metadata.Copyright)); LoggingManager.Instance.Logger.Debug("analyse assembly finished"); return(null); }
/// <summary> /// determines if the package information can be used to deploy, if not an exception will be thrown /// </summary> private void ValidatePackageInformation(PackageInformation packageInfo) { //TODO needs to determine more here, so we can make sure that everything is covered if (string.IsNullOrEmpty(packageInfo.NuSpecPackage.Metadata.Version) || packageInfo.NuSpecPackage.Metadata.Version == Resources.InvalidVersion) { throw new ProjectAnalyseFailedException(string.Format("could not create determine version of the project, make sure you used the right assembly version identifier.{0}Current settings uses {1}", Environment.NewLine, packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionIdentifier)); } }
public DownloadFileUtility(Connection connection, PackageInformation pkgInfo, ISendSafelyProgress progress, string downloadApi, string password) { _pkgInfo = pkgInfo; _progress = progress; _connection = connection; _downloadApi = downloadApi; _password = password; }
public DownloadFileUtility(Connection connection, Directory directory, PackageInformation pkgInfo, ISendSafelyProgress progress, string downloadApi) { _pkgInfo = pkgInfo; _progress = progress; _connection = connection; _downloadApi = downloadApi; _directoryInfo = directory; }
public DownloadFileUtility(Connection connection, Directory directory, PackageInformation pkgInfo, ISendSafelyProgress progress, String downloadAPI) { this.pkgInfo = pkgInfo; this.progress = progress; this.connection = connection; this.downloadAPI = downloadAPI; this.directoryInfo = directory; }
public DownloadFileUtility(Connection connection, PackageInformation pkgInfo, ISendSafelyProgress progress, String downloadAPI, String password) { this.pkgInfo = pkgInfo; this.progress = progress; this.connection = connection; this.downloadAPI = downloadAPI; this.password = password; }
/// <summary> /// add all the item from the project that match one of the file includes /// </summary> private void AddNuSpecFilesCSharpVisualBasic(ProjectItems items, PackageInformation packageInfo, ProjectInformation projectInformation) { //-----get all the include able item here foreach (ProjectItem item in items) { //-----check if the item contains an item type property string itemType = ExtensionUtil.GetPropertyValue <string>(item.Properties, projectInformation.ItemType, null); if (!string.IsNullOrEmpty(itemType)) { object itemOutput = ExtensionUtil.GetPropertyValue <object>(item.Properties, projectInformation.ItemOutput, -1); if (itemOutput != null && itemOutput.ToString() != "0") { string itemFullPath = ExtensionUtil.GetPropertyValue <string>(item.Properties, "FullPath", null); if (!string.IsNullOrEmpty(itemFullPath)) { try { string itemRelativePath = itemFullPath.Remove(0, Path.GetDirectoryName(packageInfo.ProjectFullName).Length + 1).Replace("\\", "/"); if (!itemRelativePath.Contains("/")) { itemRelativePath = string.Format("/{0}", itemRelativePath); } LoggingManager.Instance.Logger.Debug(string.Format("checking item [{0}] for a possible fit", itemRelativePath)); FileInclude fileInclude = packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Files.FileIncludes.FirstOrDefault(x => { string wildcard = string.Format("{0}/{1}", string.IsNullOrEmpty(x.Folder) ? "*" : x.Folder.Replace("\\", "/"), string.IsNullOrEmpty(x.Name) ? "*" : x.Name.Replace("\\", "/")); LoggingManager.Instance.Logger.Debug(string.Format("checking file include [{0}]", wildcard)); return(StringUtil.MatchesWildcard(itemRelativePath, wildcard)); }); if (fileInclude != null) { packageInfo.NuSpecPackage.Files.Add(new Xml.NuGet.NuSpec.File() { Source = itemFullPath, Target = fileInclude.Target }); LoggingManager.Instance.Logger.Debug(string.Format("added file [{0}] under [{1}]", itemFullPath, fileInclude.Target)); } else { LoggingManager.Instance.Logger.Info(string.Format("could not add file [{0}] because no fitting file include was found", itemFullPath)); } } catch (Exception ex) { if (ex is ThreadAbortException || ex is ThreadInterruptedException) { throw; } LoggingManager.Instance.Logger.Error(string.Format("error occured while adding the item [{0}]", itemFullPath), ex); } } } } //-----check sub items if any AddNuSpecFilesCSharpVisualBasic(item.ProjectItems, packageInfo, projectInformation); } }
public Task <IEnumerable <SnapShot> > GetSnapShotsAsync(PackageInformation package) { return(Task.Factory.StartNew <IEnumerable <SnapShot> >(() => { var list = new List <SnapShot>(); string appDataPath = GetPathForUserDataStorage(package); list.AddRange(GetSnapShots(appDataPath)); return list; })); }
private void Install([NotNull] PackageInformation package) { Debug.ArgumentNotNull(package, nameof(package)); var d = new InstallPackageDialog(); d.Initialize(package.Site, package.ServerFileName); AppHost.Shell.ShowDialog(d); }
public void Apply(ParticipantCreated e) { Name = e.Name; Gender = e.Gender; IsDelegate = e.IsDelegate; IsGuest = e.IsGuest; YearsQualifying = e.YearsQualifying; Birthday = e.Birthday; Package = new PackageInformation(); Profile = new ProfileDetails(); }
/// <summary> /// prepares the project and stores all the needed information in local variables /// </summary> /// <param name="activeProject">project that is supposed to be deployed, must not be null</param> /// <returns>null if the preparation was successfull, otherwise the error string</returns> private void PreAnalyseProject(Project activeProject, out PackageInformation packageInfo, out ProjectInformation projectInformation) { LoggingManager.Instance.Logger.Debug("prepare project started"); if (activeProject == null) { throw new ArgumentNullException("activeProject", "given project must not be null"); } //-----assign incoming values packageInfo = null; projectInformation = null; //-----make sure the project is supported projectInformation = OptionsManager.Instance.SupportedProjectInformation.FirstOrDefault(p => activeProject.FullName.EndsWith(p.Extension)); if (projectInformation == null) { throw new ProjectNoSupportedException("project not supported"); } //-----make sure the project is not being deployed already try { if (Mutex.OpenExisting(activeProject.FullName.GetHashCode().ToString()) != null) { throw new ProjectIsBeingDeployedException("project is already being deployed"); } } catch (WaitHandleCannotBeOpenedException) { LoggingManager.Instance.Logger.Debug(string.Format("project {0} is currently not being deployed", activeProject.FullName)); } //-----get the project options, which will either be used or project based string configFullName; Enumerations.ProjectIdentifier identifier = projectInformation.Identifier; Xml.Settings.Project.Options projectOptions = OptionsManager.Instance.DetermineProjectConfiguration(activeProject, identifier, out configFullName, true); //-----create the deployment info packageInfo = new PackageInformation() { ProjectOptions = projectOptions, NuSpecPackage = new Xml.NuGet.NuSpec.Package() { Metadata = new Xml.NuGet.NuSpec.Metadata() }, Build = new BuildOptions(), ProjectFullName = activeProject.FullName, }; LoggingManager.Instance.Logger.Debug("prepare project finished"); }
public Task <IEnumerable <PackageInformation> > GetInstalledPackagesAsync() { return(Task.Factory.StartNew <IEnumerable <PackageInformation> >(() => { var listOfApps = new List <PackageInformation>(); try { var packagesDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Constants.DirectoryNames.Name); var packageManager = new Windows.Management.Deployment.PackageManager(); var packages = packageManager.FindPackagesForUser(System.Security.Principal.WindowsIdentity.GetCurrent().User.Value); if (packages != null && packages.Any()) { foreach (var package in packages) { try { var app = new PackageInformation() { AppVersion = new Version(package.Id.Version.Major, package.Id.Version.Minor, package.Id.Version.Build, package.Id.Version.Revision), DataDirectory = Path.Combine(packagesDirectory, package.Id.FamilyName), FamilyName = package.Id.FamilyName, FullName = package.Id.FullName, Name = package.Id.Name, Publisher = package.Id.PublisherId, }; try { if (null != package.InstalledLocation) { app.InstallationDirectory = package.InstalledLocation.Path; } } catch (Exception) { Logger.Log(Logger.LogSeverity.Warning, "App package has no install location: ({0})", package.Id.FullName); } listOfApps.Add(app); } catch (Exception ex) { Logger.Log(ex, "Error while loading information for package: ({0})", package.Id.FullName); } } } } catch (Exception ex) { Logger.Log(ex, "Exception while loading list of installed packages"); } return listOfApps; })); }
public PackageListBoxItem([NotNull] PackageInformation package, [NotNull] Action <PackageInformation> install) { Assert.ArgumentNotNull(package, nameof(package)); Assert.ArgumentNotNull(install, nameof(install)); InitializeComponent(); Package = package; InstallButton.Click += (sender, args) => install(package); RenderPackage(); }
public Task <bool> DoesSnapShotAlreadyExistAsync(PackageInformation package, string snapShotName) { return(Task.Factory.StartNew <bool>(() => { bool doesExist = false; var basePath = GetPathForUserDataStorage(package); string pathToSnapShot = Path.Combine(basePath, snapShotName); if (Directory.Exists(pathToSnapShot)) { doesExist = true; } return doesExist; })); }
public Task <string> GenerateNewSnapShotAsync(PackageInformation package, string snapShotName) { return(Task.Factory.StartNew <string>(() => { string pathToSnapShot = Path.Combine(GetPathForUserDataStorage(package), snapShotName); Directory.CreateDirectory(pathToSnapShot); string liveSettings = Path.Combine(package.DataDirectory, Constants.DirectoryNames.Settings); string liveLocal = Path.Combine(package.DataDirectory, Constants.DirectoryNames.LocalState); string savedSettings = Path.Combine(pathToSnapShot, Constants.DirectoryNames.Settings); string savedLocal = Path.Combine(pathToSnapShot, Constants.DirectoryNames.LocalState); DirectoryCopy(liveSettings, savedSettings, true, true); DirectoryCopy(liveLocal, savedLocal, true, true); return pathToSnapShot; })); }
public Task <bool> RemoveSnapShotAsync(PackageInformation package, string snapShotName) { return(Task.Factory.StartNew <bool>(() => { if (package != null && !String.IsNullOrWhiteSpace(snapShotName)) { string pathToSnapShot = Path.Combine(GetPathForUserDataStorage(package), snapShotName); if (Directory.Exists(pathToSnapShot)) { DeleteDirectory(pathToSnapShot, true); } } return true; })); }
private static string GetPathForUserDataStorage(PackageInformation package) { string path = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constants.DirectoryNames.WindowsAppBoss, Constants.DirectoryNames.SnapShots, package.Name ); if (!System.IO.File.Exists(path)) { Directory.CreateDirectory(path); } return(path); }
/// <summary> /// prepares the project so all the needed projects information are known /// <para>those information is stored in the given transit and container object</para> /// <para>this method is intended to be used after the prepare method has been called</para> /// </summary> /// <param name="activeProject">project to analyse, must not be null</param> /// <param name="packageInfo">transit object used to store the analysed information, must not be null</param> /// <param name="container">container object which contains information needed to analyse the project,</param> /// <returns>null if the analyse process was successfull, otherwise the error message is returned</returns> private void AnalyseProject(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation) { LoggingManager.Instance.Logger.Debug("analsye project started"); if (activeProject == null) { throw new ArgumentNullException("activeProject", "given project must not be null"); } if (packageInfo == null) { throw new ArgumentNullException("transit", "given transit must not be null"); } if (projectInformation == null) { throw new ArgumentNullException("projectInformation", "given projectInformation must not be null"); } string monikerValue = null; //----- analyse the project dependent on the identifier AnalyseAssembly(activeProject, packageInfo, projectInformation, out monikerValue); //-----get the nuget target Xml.Settings.General.NuGet.Target nuGetTarget = null; try { nuGetTarget = OptionsManager.Instance.Configuration.GeneralOptions.NuGetOptions.Targets.First(tf => tf.Moniker == monikerValue); } catch (InvalidOperationException ex) { throw new UnkownMonikerException(monikerValue, string.Format("given moniker {0} is not known", monikerValue), ex); } ChangeNuSpec(activeProject, packageInfo); DetermineBuildOptions(activeProject, packageInfo, projectInformation); DetermineNuSpecFiles(activeProject, packageInfo, projectInformation, nuGetTarget); DetermineNuSpecDependecies(activeProject, packageInfo); CheckNuSpecFile(activeProject, packageInfo); ValidatePackageInformation(packageInfo); LoggingManager.Instance.Logger.Debug("analsye project finished"); }
private void Install([NotNull] PackageInformation package) { Debug.ArgumentNotNull(package, nameof(package)); if (AppHost.MessageBox("The package will be uploaded to the web site before installing.\n\nAre you sure you want to continue?", Resources.Confirmation, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK) { return; } var fileName = package.LocalFileName; if (!DataService.CheckFileSize(fileName, package.Site.Connection)) { return; } var contents = File.ReadAllBytes(fileName); var data = Convert.ToBase64String(contents); ExecuteCompleted completed = delegate(string response, ExecuteResult result) { if (!DataService.HandleExecute(response, result)) { return; } package.ServerFileName = response; var packageListBox = PackageListBox; if (packageListBox != null) { var packageManager = packageListBox.GetAncestor <PackageManagerDialog>(); if (packageManager != null) { packageManager.RefreshSiteRepositories(); } } var d = new InstallPackageDialog(); d.Initialize(package.Site, package.ServerFileName); AppHost.Shell.ShowDialog(d); }; package.Site.DataService.ExecuteAsync("Packages.Upload", completed, data, Path.GetFileName(fileName)); }
private ValidResult savesBy(IEnumerable <Detail> details) { var packageInformation = PackageInformation.CreateInstance(string.Empty); packageInformation.Id = Guid.NewGuid(); packageInformation.IsReadComplate = true; var validResult = new ValidResult(); foreach (var detail in details) { detail.Recorder = HttpContext.User.Claims.FirstOrDefault(p => p.Type == ClaimTypes.Name).Value; detail.PackageInformation = packageInformation; this.validBy(validResult, detail); } if (!validResult.IsValid) { return(validResult); } try { foreach (var detail in details) { if (detailRepository.Exist(detail.Id)) { detailRepository.Update(detail); } else { detailRepository.Create(detail).Wait(); } } } catch (Exception exception) { logger.LogError(JsonConvert.SerializeObject(details)); throw exception; } return(validResult); }
/// <summary> /// edits certain project based values for c# and visual studio projects /// </summary> /// <param name="activeProject">the active project that is to be deployed</param> /// <param name="project">project configuration to use</param> /// <returns>null if all edits were down, otherwise the error string</returns> private void ChangeNuSpec(Project activeProject, PackageInformation packageInfo) { LoggingManager.Instance.Logger.Debug("changing project started"); //-----edit values here if (!string.IsNullOrEmpty(packageInfo.NuSpecPackage.Metadata.Version) && packageInfo.ProjectOptions.GeneralOptions.VersionComponent.HasValue) { LoggingManager.Instance.Logger.Debug(string.Format("changing version [{0}]", packageInfo.NuSpecPackage.Metadata.Version)); HashSet <VersionComponentInfo> version = VersionUtil.GetVersion(packageInfo.NuSpecPackage.Metadata.Version, null, packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionInformationalSeparator); VersionUtil.IncreaseVersion(version, packageInfo.ProjectOptions.GeneralOptions.VersionComponent.Value, null, packageInfo.ProjectOptions.GeneralOptions.HandleIncrementOverflow); packageInfo.NuSpecPackage.Metadata.Version = VersionUtil.CreateVersion(version, null, packageInfo.ProjectOptions.GeneralOptions.AssemblyInfoVersionInformationalSeparator); LoggingManager.Instance.Logger.Debug(string.Format("new version [{0}]", packageInfo.NuSpecPackage.Metadata.Version)); } LoggingManager.Instance.Logger.Debug("changing project finished"); }
private Endpoint CreateEndpoint(PackageInformation pkgInfo, string fileId) { Endpoint p; if (_directoryInfo != null) { p = ConnectionStrings.Endpoints["downloadFileFromDirectory"].Clone(); p.Path = p.Path.Replace("{packageId}", pkgInfo.PackageId); p.Path = p.Path.Replace("{fileId}", fileId); p.Path = p.Path.Replace("{directoryId}", _directoryInfo.DirectoryId); } else { p = ConnectionStrings.Endpoints["downloadFile"].Clone(); p.Path = p.Path.Replace("{packageId}", pkgInfo.PackageId); p.Path = p.Path.Replace("{fileId}", fileId); } return(p); }
static void Resolve(string file, IDictionary <string, PackageInformation> packages) { var dir = Path.GetDirectoryName(file); var filesInDir = Directory.GetFiles(dir); var csproj = filesInDir.Single(x => x.EndsWith(".csproj")); var assemblyPattern = @"<AssemblyName>(.*)<\/AssemblyName>"; var csprojFile = File.ReadAllText(csproj); var assemblyName = Regex.Match(csprojFile, assemblyPattern).Groups[1].Value; var packageXml = new XmlDocument(); packageXml.Load(file); var packagesElement = packageXml.GetElementsByTagName("package"); foreach (XmlNode package in packagesElement) { var packageId = package.Attributes["id"].Value; var packageVersion = package.Attributes["version"].Value; var targetFramework = package.Attributes["targetFramework"].Value; packages.TryGetValue(packageId, out var addedPackage); if (addedPackage == null) { addedPackage = new PackageInformation(packageId); packages.Add(packageId, addedPackage); } addedPackage.Versions.Add(packageVersion); addedPackage.TargetFrameworks.Add(targetFramework); addedPackage.Assemblies.Add(assemblyName); } }
/// <summary> /// accesses the document library at the path provided, /// loops through the learning packages /// located the library and reads the package Id from package manifest /// </summary> /// <param name="siteURL">web site url</param> /// <param name="documentLibraryName">document library name</param> /// <returns></returns> public Hashtable GetAllLearningResources(string siteURL, string documentLibraryName) { Hashtable resources = new Hashtable(); SharePointV3 sharepoint = new SharePointV3(); SPWeb documentLibWeb = sharepoint.OpenWeb(siteURL); SPDocumentLibrary docLibrary = sharepoint.GetDocumentLibrary(documentLibraryName, documentLibWeb); Microsoft.SharePointLearningKit.SlkStore store = SlkStore.GetStore(documentLibWeb); foreach (SPListItem item in docLibrary.Items) { //if this list item is a file if (item.File != null) { SharePointFileLocation fileLocation = new SharePointFileLocation(documentLibWeb, item.UniqueId, item.File.UIVersion); string location = fileLocation.ToString(); try { PackageInformation info = store.GetPackageInformation(location); XPathNavigator manifestNavigator = info.ManifestReader.CreateNavigator(); Guid packageIdentifier = ManifestParser.ParseIndexXml(manifestNavigator); if (packageIdentifier == Guid.Empty) { packageIdentifier = ManifestParser.ParseImsManifestXml(manifestNavigator); } if (packageIdentifier != Guid.Empty) { resources.Add(packageIdentifier.ToString(), location); } } catch { //not a valid learning package, do nothing } } } return(resources); }
public OneTargetUpdater(ComponentTarget Target, FirmwareComponent Component, PackageInformation Information) { this.Target = Target; this.Component = Component; this.Information = Information; }
public FakeRepositoryElement(PackageInformation Information, ReleaseStatus Status = ReleaseStatus.Unknown) { this.Status = Status; this.Information = Information; Targets = new[] { new ComponentTarget(1, 1, 1, 1) }; }
public FakeFirmwareSelectorViewModel(string Name, PackageInformation PackageInformation) : base(Name) { _packageInformation = PackageInformation; SelectedPackage = new FirmwarePackageViewModel("sdfsdf", new FirmwareVersionViewModel("3.2", "LDS", DateTime.Now), new FirmwarePackageAvailabilityViewModel(true), ReleaseStatus.Unknown, null); }
public ModuleProject(ModuleInformation Information, PackageInformation FirmwareInformation, FirmwareComponent FirmwareContent) { this.Information = Information; this.FirmwareInformation = FirmwareInformation; this.FirmwareContent = FirmwareContent; }
public void SynchronizeComponent(FirmwareComponent Component, PackageInformation FirmwareInformation, IProgressAcceptor GlobalProgressAcceptor = null, IProgressAcceptor LocalProgressAcceptor = null) { // Проверяем, можно ли применить программный компонент к данной прошивке if (!Component.Targets.Any(ct => CanApply(ct, Session.Device))) throw new CanUpdateComponentMismatchException(); bool forceReplace = false; #if DEBUG forceReplace = true; #endif PostProgressMessage(GlobalProgressAcceptor, "Получение списка файлов"); var filesOnDevice = Session.ListFiles(); _logger.Debug("FILES:{0}", string.Join("", filesOnDevice.Select(f => String.Format("{3} {0,-16} {1:N0} Bytes [0x{2:x4}]", f.FileName, f.FileSize, f.ControlSum, Environment.NewLine)))); var filesInComponent = Component.Files; var filesToRemove = filesOnDevice.Where(df => filesInComponent.All(cf => cf.RelativePath != df.FileName)).ToList(); var filesToReplace = filesInComponent.Select(componentFile => new { componentFile, deviceFile = filesOnDevice.FirstOrDefault(f => f.FileName == componentFile.RelativePath) }) .Where( pair => pair.deviceFile == null || forceReplace || pair.deviceFile.ControlSum != FudpCrc.CalcCrc(pair.componentFile.Content)) .ToList(); int transferWeight = filesToReplace.Sum(pair => pair.componentFile.Content.Length); try { PostProgressMessage(GlobalProgressAcceptor, "Передача прошивки {0:P0}"); foreach (var fileToRemove in filesToRemove) { PostProgressMessage(LocalProgressAcceptor, "Удаление файла " + fileToRemove.FileName); RemoveFile(fileToRemove); _logger.Info("Файл {0} удалён с устройства", fileToRemove.FileName); } double totalTransferred = 0; foreach (var filePairToReplace in filesToReplace) { IProgressAcceptor subProgressAcceptor = null; if (GlobalProgressAcceptor != null) { subProgressAcceptor = new SubprogressAcceptorRetranslator( GlobalProgressAcceptor, LocalProgressAcceptor, totalTransferred / transferWeight, (double)filePairToReplace.componentFile.Content.Length / transferWeight); } _logger.Info(filePairToReplace.deviceFile == null ? "Создание файла {0}" : "Перезапись файла {0}", filePairToReplace.componentFile); PushFile(filePairToReplace.componentFile, filePairToReplace.deviceFile != null, GlobalProgressAcceptor, subProgressAcceptor); _logger.Info("Файл {0} передан на устройство", filePairToReplace.componentFile); totalTransferred += filePairToReplace.componentFile.Content.Length; } PostProgressMessage(GlobalProgressAcceptor, "Обновление свойств"); Session.SetParam(ParamKeys.MajorVersion, FirmwareInformation.FirmwareVersion.Major); Session.SetParam(ParamKeys.MinorVersion, FirmwareInformation.FirmwareVersion.Minor); Session.SetParam(ParamKeys.LastUpgrateDate, DateTimeFormatter.ToUnixTime(DateTime.Now)); Session.SetParam(ParamKeys.GlobalChecksum, GetGlobalChecksum(Component)); Session.SetParam(ParamKeys.VersionLabel, LabelEncoder.Default.Encode(FirmwareInformation.FirmwareVersionLabel)); _logger.Info("Свойства загрузчика обновлены"); } catch (CanProgFileopException exc) { throw new CanUpdateFileOperationException(exc); } }
/// <summary>Инициализирует новый экземпляр класса <see cref="T:System.Object" />.</summary> public FakeRepositoryElement(PackageInformation Information, ICollection<ComponentTarget> Targets, ReleaseStatus Status) { this.Status = Status; this.Information = Information; this.Targets = Targets; }