Exemplo n.º 1
0
        private bool AddIsolatedComReferences(ApplicationManifest manifest)
        {
            int  t1      = Environment.TickCount;
            bool success = true;

            if (IsolatedComReferences != null)
            {
                foreach (ITaskItem item in IsolatedComReferences)
                {
                    string name = item.GetMetadata("Name");
                    if (String.IsNullOrEmpty(name))
                    {
                        name = Path.GetFileName(item.ItemSpec);
                    }
                    FileReference file = AddFileFromItem(item);
                    if (!file.ImportComComponent(item.ItemSpec, manifest.OutputMessages, name))
                    {
                        success = false;
                    }
                }
            }

            Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "GenerateApplicationManifest.AddIsolatedComReferences t={0}", Environment.TickCount - t1));
            return(success);
        }
Exemplo n.º 2
0
        private string SetEntryPointAndConfig(ApplicationManifest manifest, string fileName, AssemblyReference asmRef)
        {
            string entryPointFileName = Path.GetFileName(fileName);

            manifest.EntryPoint       = asmRef;
            manifest.AssemblyIdentity = AssemblyIdentity.FromFile(fileName);
            if (UseConfigName)
            {
                manifest.AssemblyIdentity.Name = entryPointFileName + "_" + this.ConfigName;
            }
            else
            {
                manifest.AssemblyIdentity.Name = entryPointFileName;
            }

            if (ConfigFile != null)
            {
                string        configFilePath = Path.GetFullPath(ConfigFile.ItemSpec);
                FileReference configRef      = new FileReference(configFilePath);
                string        configFileName = entryPointFileName + ".config";
                configRef.TargetPath = configFileName;
                manifest.FileReferences.Add(configRef);

                return(configFileName);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        private bool BuildResolvedSettings(ApplicationManifest manifest)
        {
            // Note: if changing the logic in this function, please update the logic in
            //  GenerateDeploymentManifest.BuildResolvedSettings as well.
            if (Product != null)
            {
                manifest.Product = Product;
            }
            else if (String.IsNullOrEmpty(manifest.Product))
            {
                manifest.Product = Path.GetFileNameWithoutExtension(manifest.AssemblyIdentity.Name);
            }
            Debug.Assert(!String.IsNullOrEmpty(manifest.Product));

            if (Publisher != null)
            {
                manifest.Publisher = Publisher;
            }
            else if (String.IsNullOrEmpty(manifest.Publisher))
            {
                string org = Util.GetRegisteredOrganization();
                if (!String.IsNullOrEmpty(org))
                {
                    manifest.Publisher = org;
                }
                else
                {
                    manifest.Publisher = manifest.Product;
                }
            }
            Debug.Assert(!String.IsNullOrEmpty(manifest.Publisher));

            return(true);
        }
 private bool BuildResolvedSettings(ApplicationManifest manifest)
 {
     if (this.Product != null)
     {
         manifest.Product = this.Product;
     }
     else if (string.IsNullOrEmpty(manifest.Product))
     {
         manifest.Product = Path.GetFileNameWithoutExtension(manifest.AssemblyIdentity.Name);
     }
     if (this.Publisher != null)
     {
         manifest.Publisher = this.Publisher;
     }
     else if (string.IsNullOrEmpty(manifest.Publisher))
     {
         string registeredOrganization = Util.GetRegisteredOrganization();
         if (!string.IsNullOrEmpty(registeredOrganization))
         {
             manifest.Publisher = registeredOrganization;
         }
         else
         {
             manifest.Publisher = manifest.Product;
         }
     }
     return(true);
 }
        /// <summary>
        /// Returns a collection of application files from the assembly and file references in the provided app manifest
        /// </summary>
        /// <param name="appManifest">App manifest to inspect</param>
        /// <returns>List of ApplicationFile instances with the info from the manifest file list</returns>
        public static BindingList <ApplicationFile> GetFiles(ApplicationManifest appManifest)
        {
            BindingList <ApplicationFile> files = new BindingList <ApplicationFile>();

            // Populate collection with assembly references
            foreach (AssemblyReference assemRef in appManifest.AssemblyReferences)
            {
                if (assemRef.IsPrerequisite)
                {
                    continue;
                }
                ApplicationFile appFile = new ApplicationFile();
                appFile.FileName     = Path.GetFileName(assemRef.TargetPath);
                appFile.RelativePath = Path.GetDirectoryName(assemRef.TargetPath);
                appFile.DataFile     = false;
                if (appManifest.EntryPoint == assemRef)
                {
                    appFile.EntryPoint = true;
                }
                files.Add(appFile);
            }

            // Populate collection with file references
            foreach (FileReference fileRef in appManifest.FileReferences)
            {
                ApplicationFile appFile = new ApplicationFile();
                appFile.FileName     = Path.GetFileName(fileRef.TargetPath);
                appFile.RelativePath = Path.GetDirectoryName(fileRef.TargetPath);
                appFile.DataFile     = fileRef.IsDataFile;
                files.Add(appFile);
            }
            return(files);
        }
Exemplo n.º 6
0
        private static void AddFileAssociations(this ApplicationManifest application, Project project)
        {
            Logger.Normal(Messages.Build_Process_FileAssociations);

            if (project.FileAssociations.Value is null)
            {
                Logger.Normal(Messages.Result_NoneFound, 1, 2);
                return;
            }

            foreach (var item  in project.FileAssociations.Value.Split(':'))
            {
                var elements        = item.Split(';');
                var fileAssociation = new FileAssociation
                {
                    Extension   = elements[0],
                    Description = elements[1],
                    ProgId      = elements[2],
                    DefaultIcon = elements[3]
                };
                Logger.Normal(fileAssociation.Extension, 1);
                application.FileAssociations.Add(fileAssociation);
                application.Add(project, Path.Combine(project.Source.Value, fileAssociation.DefaultIcon), fileAssociation.DefaultIcon, GlobKind.Files);
            }
            Logger.Normal();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Add application manifest details to a deployment manifest
        /// </summary>
        /// <param name="deploymentManifest">DeploymentManifest object</param>
        /// <param name="deploymentManifestPath">Deployment manifest path</param>
        /// <param name="applicationManifest">ApplicationManifest object</param>
        /// <param name="applicationManifestPath">Application manifest path</param>
        /// <param name="targetFrameworkVersion">Target Framework version</param>
        private static void SetApplicationManifestReference(
            DeployManifest deploymentManifest,
            string deploymentManifestPath,
            ApplicationManifest applicationManifest,
            string applicationManifestPath,
            string targetFrameworkVersion)
        {
            // Validate parameters
            if ((deploymentManifest == null) || (applicationManifest == null) ||
                (deploymentManifestPath == null) || (applicationManifestPath == null))
            {
                Application.PrintErrorMessage(ErrorMessages.InternalError);
                return;
            }

            // Get absolute directory paths for both path parameters
            if (!Path.IsPathRooted(deploymentManifestPath))
            {
                deploymentManifestPath = Path.Combine(Environment.CurrentDirectory, deploymentManifestPath);
            }

            if (!Path.IsPathRooted(applicationManifestPath))
            {
                applicationManifestPath = Path.Combine(Environment.CurrentDirectory, applicationManifestPath);
            }

            string deploymentManifestDir  = Path.GetDirectoryName(deploymentManifestPath);
            string applicationManifestDir = Path.GetDirectoryName(applicationManifestPath);

            // Codebase defaults to a canonical string from the application manifest identity
            string codebase = applicationManifest.AssemblyIdentity.Version + "\\" + applicationManifest.AssemblyIdentity.Name + ".manifest";

            // Use relative codebase if possible
            if (applicationManifestDir.StartsWith(deploymentManifestDir, StringComparison.OrdinalIgnoreCase))
            {
                codebase = applicationManifestPath.Substring(deploymentManifestDir.Length);

                if (codebase.StartsWith("\\"))
                {
                    codebase = codebase.Substring(1);
                }
            }

            // Create a new assembly reference for the application manifest
            AssemblyReference ar = new AssemblyReference(applicationManifestPath)
            {
                AssemblyIdentity = applicationManifest.AssemblyIdentity
            };

            // Update the deployment manifest
            deploymentManifest.AssemblyReferences.Clear();
            deploymentManifest.AssemblyReferences.Add(ar);
            deploymentManifest.EntryPoint = ar;
            deploymentManifest.ResolveFiles();
            deploymentManifest.UpdateFileInfo(targetFrameworkVersion);

            // Update the codebase so the canonical one gets used even if the application manifest
            // happens to live somewhere else at the moment.
            ar.TargetPath = codebase;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Generates Deployment manifest
        /// </summary>
        /// <param name="deploymentManifestPath">Path of generated deployment manifest</param>
        /// <param name="appName">Application name</param>
        /// <param name="version">Version</param>
        /// <param name="processor">Processor type</param>
        /// <param name="applicationManifest">Application manifest from which to extract deployment details</param>
        /// <param name="applicationManifestPath">Path to application manifest</param>
        /// <param name="appCodeBase">Application codebase</param>
        /// <param name="appProviderUrl">Application provider URL</param>
        /// <param name="minVersion">Minimum version</param>
        /// <param name="install">Install state</param>
        /// <param name="includeDeploymentProviderUrl"></param>
        /// <param name="publisherName">Publisher name</param>
        /// <param name="supportUrl">Support URL</param>
        /// <param name="targetFrameworkVersion">Target Framework version</param>
        /// <returns>DeploymentManifest object</returns>
        public static DeployManifest GenerateDeploymentManifest(string deploymentManifestPath,
                                                                string appName, Version version, Processors processor,
                                                                ApplicationManifest applicationManifest, string applicationManifestPath, string appCodeBase,
                                                                string appProviderUrl, string minVersion, TriStateBool install, TriStateBool includeDeploymentProviderUrl,
                                                                string publisherName, string supportUrl, string targetFrameworkVersion)
        {
            /*
             * Mage running on Core cannot obtain .NET FX version for targeting.
             * Set default minimum version to v4.5, that Launcher targets,
             * which is a good default for .NET FX Mage as well.
             *
             * As always, version can be modified in deployment manifest, if needed.
             */
            Version shortVersion        = new Version(4, 5);
            string  frameworkIdentifier = ".NETFramework";

            DeployManifest manifest = new DeployManifest((new FrameworkName(frameworkIdentifier, shortVersion)).FullName);

            // Set default manifest publish options
            if (install == TriStateBool.True)
            {
                manifest.Install       = true;
                manifest.UpdateEnabled = true;
                manifest.UpdateMode    = UpdateMode.Background;
            }
            else
            {
                manifest.Install = false;
            }

            // Use default application name if none was specified
            if (appName == null)
            {
                appName = Application.Resources.GetString("DefaultAppName");
            }

            // Use default version if none was specified
            if (version == null)
            {
                version = defaultVersion;
            }

            // Use default processor if none was specified
            if (processor == Processors.Undefined)
            {
                processor = Processors.msil;
            }

            // Use default provider URL if none was specified
            if (appProviderUrl == null)
            {
                appProviderUrl = "";
            }

            UpdateDeploymentManifest(manifest, deploymentManifestPath, appName, version, processor,
                                     applicationManifest, applicationManifestPath, appCodeBase,
                                     appProviderUrl, minVersion, install, includeDeploymentProviderUrl, publisherName, supportUrl, targetFrameworkVersion);

            return(manifest);
        }
        /// <summary>
        /// Allows user to point to a different app manifest
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSelectAppManifest(object sender, EventArgs e)
        {
            // Prompt for path
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Application Manifests (*.manifest)|*.manifest|All Files (*.*)|*.*";

            // Use last path if available
            if (!string.IsNullOrEmpty(Settings.Default.LastManifestPath) &&
                (Directory.Exists(Settings.Default.LastManifestPath)))
            {
                ofd.InitialDirectory = Settings.Default.LastManifestPath;
            }

            // Load file list if user selects manifest
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string fileName = ofd.FileName;
                try
                {
                    m_AppManifest   = ManifestHelper.LoadAppManifest(fileName);
                    m_Prerequisites = ManifestHelper.GetPrerequisites(m_AppManifest);
                    m_Files         = ManifestHelper.GetFiles(m_AppManifest);
                    filesBindingSource.DataSource = m_Files;
                    ManifestHelper.UpdateDeployManifestAppReference(m_DeployManifest, m_AppManifest);
                    appManifestPathTextBox.Text = m_DeployManifest.EntryPoint.TargetPath;
                    EnableToolStripItems(true);
                }
                catch
                {
                    MessageBox.Show("Invalid manifest");
                }
            }
        }
        /// <summary>
        /// Disconnect from the Server and cleanup
        /// </summary>
        /// <remarks> In order to disconnect we need to dispose the ServerAgent object.
        /// Derived classes should always call base.InternalDisconnect from their overrides.
        /// </remarks>
        protected virtual void InternalDisconnect(ConnectionDroppedEventArgs cde)
        {
            ServerAgent serverAgentToDispose = serverAgent;

            if (serverAgentToDispose != null)
            {
                serverAgent         = null;
                applicationManifest = null;

                //
                // Stop event manager.
                //

                quitHandle.Set();
                eventManager.Join(1000 /* upto a second */);
                eventManager = null;

                try {
                    //
                    // Disconnect from server.
                    //

                    serverAgentToDispose.Dispose();
                }
                catch (Exception e) {
                    Debug.Write(e.Message);
                }
            }

            return;
        }
        /// <summary>
        /// Load and compile the application manifest, and try
        /// to connect to the Live Communications Server.
        /// </summary>
        /// <exception cref="System.Exception">If unable to
        /// connect. The exception string contains the details
        /// </exception>
        /// <param name="manifestFile">file name of the SPL manifest.
        /// This file must be present in the working directory of the
        /// executable
        /// </param>
        /// <param name="applicationName">A friendly name for use while
        /// registering with WMI. Use a null value if you dont want
        /// the function to do registration
        /// </param>
        /// <param name="appGuid">Guid for use during WMI registration.
        /// If a null guid is specified but applicationName is not
        /// null, a new guid will be generated, used, and returned.
        /// </param>
        /// <seealso cref="Microsoft.Rtc.Sip.CompilerErrorException"/>
        /// <seealso cref="Microsoft.Rtc.Sip.ServerAgent"/>
        public void ConnectToServer(string manifestFile, string applicationName, ref string appGuid)
        {
            ///load and compile the application manifest
            applicationManifest = ApplicationManifest.CreateFromFile(manifestFile);
            if (applicationManifest == null)
            {
                throw new Exception(
                          String.Format("The manifest file {0} was not found", manifestFile));
            }

            try {
                applicationManifest.Compile();

                ///try to connect to server
                serverAgent = new ServerAgent(this, applicationManifest);
            }
            catch (CompilerErrorException cee) {
                ///collapse all compiler errors into one, and return it
                StringBuilder sb = new StringBuilder(1024, 1024);
                foreach (string errorMessage in cee.ErrorMessages)
                {
                    if (errorMessage.Length + sb.Length + 2 < sb.MaxCapacity)
                    {
                        sb.Append(errorMessage);
                        sb.Append("\r\n");
                    }
                    else
                    {
                        ///compiler returns really large error message
                        ///so just return what we can accomodate
                        sb.Append(errorMessage.Substring(0, sb.MaxCapacity - sb.Length - 1));
                        break;
                    }
                }

                throw new Exception(sb.ToString());
            }
            catch (Exception e) {
                if (applicationManifest != null)
                {
                    applicationManifest = null;
                }

                //ServerNotFoundException || UnauthorizedException
                throw e;
            }


            ///hook the connection dropped event handler
            serverAgent.ConnectionDropped += new ConnectionDroppedEventHandler(this.ConnectionDroppedHandler);  //ConnectionDroppedEventHandler

            ///start the eventManager thread after making sure one is
            ///not already running
            eventManagerQuit.Reset();
            eventManagerThread = new Thread(new ThreadStart(EventManagerHandler));
            eventManagerThread.Start();

            return;
        }
 private bool BuildApplicationManifest(ApplicationManifest manifest)
 {
     if (this.Dependencies != null)
     {
         foreach (ITaskItem item in this.Dependencies)
         {
             base.AddAssemblyFromItem(item);
         }
     }
     if (this.Files != null)
     {
         foreach (ITaskItem item2 in this.Files)
         {
             base.AddFileFromItem(item2);
         }
     }
     manifest.IsClickOnceManifest = this.manifestType == _ManifestType.ClickOnce;
     if (manifest.IsClickOnceManifest)
     {
         if ((manifest.EntryPoint == null) && (Util.CompareFrameworkVersions(base.TargetFrameworkVersion, "v3.5") < 0))
         {
             base.Log.LogErrorWithCodeFromResources("GenerateManifest.NoEntryPoint", new object[0]);
             return(false);
         }
         if (!this.AddClickOnceFiles(manifest))
         {
             return(false);
         }
         if (!this.AddClickOnceFileAssociations(manifest))
         {
             return(false);
         }
     }
     if (this.HostInBrowser && (Util.CompareFrameworkVersions(base.TargetFrameworkVersion, "v3.0") < 0))
     {
         base.Log.LogErrorWithCodeFromResources("GenerateManifest.HostInBrowserInvalidFrameworkVersion", new object[0]);
         return(false);
     }
     if (!this.AddIsolatedComReferences(manifest))
     {
         return(false);
     }
     manifest.MaxTargetPath       = base.MaxTargetPath;
     manifest.HostInBrowser       = this.HostInBrowser;
     manifest.UseApplicationTrust = this.UseApplicationTrust;
     if (this.UseApplicationTrust && (this.SupportUrl != null))
     {
         manifest.SupportUrl = this.SupportUrl;
     }
     if (this.UseApplicationTrust && (this.SuiteName != null))
     {
         manifest.SuiteName = this.SuiteName;
     }
     if (this.UseApplicationTrust && (this.ErrorReportUrl != null))
     {
         manifest.ErrorReportUrl = this.ErrorReportUrl;
     }
     return(true);
 }
Exemplo n.º 13
0
        private void persist(IFileSystem fileSystem, ManifestInput input, ApplicationManifest manifest)
        {
            Console.WriteLine("");
            Console.WriteLine("Persisted changes to " + FileSystem.Combine(input.AppFolder, ApplicationManifest.FILE));
            Console.WriteLine("");

            fileSystem.PersistToFile(manifest, input.AppFolder, ApplicationManifest.FILE);
        }
Exemplo n.º 14
0
        protected override void beforeEach()
        {
            theInput = new ManifestInput()
            {
                AppFolder = "some folder"
            };

            theManifest = new ApplicationManifest();
        }
Exemplo n.º 15
0
 private static void AddIconFile(this ApplicationManifest application, Project project)
 {
     Logger.Normal(Messages.Build_Process_IconFile);
     if (!application.Add(project, project.IconFile?.RootedPath, project.IconFile?.Value, GlobKind.Files))
     {
         Logger.Normal(Messages.Result_NoneFound, 1);
     }
     Logger.Normal();
 }
Exemplo n.º 16
0
        private ApplicationManifest ParseDescriptor(Stream stream)
        {
            ApplicationManifest descriptor = (ApplicationManifest)serializer.Deserialize(stream);

            descriptor.CommandLine  = descriptor.CommandLine.Replace("$(dotnet)", m_Settings.DotnetCliPath, StringComparison.InvariantCultureIgnoreCase);
            descriptor.StartPageUri = descriptor.StartPageUri.Replace("$(host-ip)", m_Settings.HostIp, StringComparison.InvariantCultureIgnoreCase);
            descriptor.IsReadyUri   = "http://localhost:5000" + descriptor.IsReadyUri;
            return(descriptor);
        }
        static ServerAgent ConnectToServer(object app, string amFile)
        {
            try
            {
                ServerAgent.WaitForServerAvailable(3);      // 3 Attempts
            }
            catch (Exception e1)
            {
                Console.WriteLine("ERROR: Server unavailable - {0}", e1.Message);
                if (e1 is UnauthorizedException)
                {
                    Console.WriteLine("must be running under an account that is a member of the \"RTC Server Applications\" local group");
                }
                return(null);
            }


            ApplicationManifest am = ApplicationManifest.CreateFromFile(amFile);

            if (am == null)
            {
                Console.WriteLine("ERROR: {0} application manifest file not found.", amFile);
                return(null);
            }

            try
            {
                am.Compile();
            }
            catch (CompilerErrorException e2)
            {
                Console.WriteLine("ERROR: {0} application manifest file contained errors:", amFile);
                foreach (string message in e2.ErrorMessages)
                {
                    Console.WriteLine(message);
                }
                return(null);
            }

            try
            {
                ServerAgent agent = new ServerAgent(app, am);
                Console.WriteLine("ServerAgent instantiated successfully with Role={0}", agent.Role.ToString());
                return(agent);
            }
            catch (Exception e3)
            {
                Console.WriteLine("ERROR: Unable insnatiate ServerAgent and to connect to server - {0}", e3.Message);
                Console.WriteLine("ERROR: type - {0}", e3.GetType().ToString());
                Console.WriteLine("ERROR: stacktrace: {0}", e3.StackTrace);
                if (e3.InnerException != null)
                {
                    Console.WriteLine("ERROR: inner exception: {0} ", e3.InnerException.Message);
                }
                return(null);
            }
        }
        private bool AddClickOnceFiles(ApplicationManifest manifest)
        {
            int tickCount = Environment.TickCount;

            if ((this.ConfigFile != null) && !string.IsNullOrEmpty(this.ConfigFile.ItemSpec))
            {
                manifest.ConfigFile = base.FindFileFromItem(this.ConfigFile).TargetPath;
            }
            if ((this.IconFile != null) && !string.IsNullOrEmpty(this.IconFile.ItemSpec))
            {
                manifest.IconFile = base.FindFileFromItem(this.IconFile).TargetPath;
            }
            if ((this.TrustInfoFile != null) && !string.IsNullOrEmpty(this.TrustInfoFile.ItemSpec))
            {
                manifest.TrustInfo = new TrustInfo();
                manifest.TrustInfo.Read(this.TrustInfoFile.ItemSpec);
            }
            if (manifest.TrustInfo == null)
            {
                manifest.TrustInfo = new TrustInfo();
            }
            if (this.OSVersion != null)
            {
                manifest.OSVersion = this.osVersion;
            }
            if (this.ClrVersion != null)
            {
                AssemblyReference assembly = manifest.AssemblyReferences.Find("Microsoft.Windows.CommonLanguageRuntime");
                if (assembly == null)
                {
                    assembly = new AssemblyReference {
                        IsPrerequisite = true
                    };
                    manifest.AssemblyReferences.Add(assembly);
                }
                assembly.AssemblyIdentity = new AssemblyIdentity("Microsoft.Windows.CommonLanguageRuntime", this.ClrVersion);
            }
            if (Util.CompareFrameworkVersions(base.TargetFrameworkVersion, "v3.0") == 0)
            {
                this.EnsureAssemblyReferenceExists(manifest, this.CreateAssemblyIdentity(Constants.NET30AssemblyIdentity));
            }
            else if (Util.CompareFrameworkVersions(base.TargetFrameworkVersion, "v3.5") == 0)
            {
                this.EnsureAssemblyReferenceExists(manifest, this.CreateAssemblyIdentity(Constants.NET30AssemblyIdentity));
                this.EnsureAssemblyReferenceExists(manifest, this.CreateAssemblyIdentity(Constants.NET35AssemblyIdentity));
                if ((!string.IsNullOrEmpty(this.TargetFrameworkSubset) && this.TargetFrameworkSubset.Equals("Client", StringComparison.OrdinalIgnoreCase)) || (!string.IsNullOrEmpty(this.TargetFrameworkProfile) && this.TargetFrameworkProfile.Equals("Client", StringComparison.OrdinalIgnoreCase)))
                {
                    this.EnsureAssemblyReferenceExists(manifest, this.CreateAssemblyIdentity(Constants.NET35ClientAssemblyIdentity));
                }
                else if (this.RequiresMinimumFramework35SP1)
                {
                    this.EnsureAssemblyReferenceExists(manifest, this.CreateAssemblyIdentity(Constants.NET35SP1AssemblyIdentity));
                }
            }
            Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "GenerateApplicationManifest.AddClickOnceFiles t={0}", new object[] { Environment.TickCount - tickCount }));
            return(true);
        }
Exemplo n.º 19
0
 private ApplicationData GetAppBinding(ApplicationManifest appManifest)
 {
     return(new ApplicationData
     {
         Name = appManifest.Name,
         Authors = appManifest.Author,
         Description = appManifest.Description,
         Type = appManifest.Type
     });
 }
Exemplo n.º 20
0
        protected override void beforeEach()
        {
            theInput = new InstallInput()
            {
                AppFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "folder1")
            };

            theManifest = new ApplicationManifest();
            Services.PartialMockTheClassUnderTest();
        }
Exemplo n.º 21
0
 private void EnsureAssemblyReferenceExists(ApplicationManifest manifest, AssemblyIdentity identity)
 {
     if (manifest.AssemblyReferences.Find(identity) == null)
     {
         AssemblyReference assembly = new AssemblyReference();
         assembly.IsPrerequisite   = true;
         assembly.AssemblyIdentity = identity;
         manifest.AssemblyReferences.Add(assembly);
     }
 }
Exemplo n.º 22
0
        public void ItShouldSetVersionOnServiceImport()
        {
            // g
            var appManifest = new ApplicationManifest
            {
                ServiceManifestImports = new List <ServiceManifestImport>
                {
                    new ServiceManifestImport
                    {
                        ServiceManifestRef = new ServiceManifestRef
                        {
                            ServiceManifestName    = "Service1",
                            ServiceManifestVersion = "1-hash"
                        }
                    },
                    new ServiceManifestImport
                    {
                        ServiceManifestRef = new ServiceManifestRef
                        {
                            ServiceManifestName    = "Service2",
                            ServiceManifestVersion = "1-hash"
                        }
                    }
                },
                ApplicationTypeName = "App"
            };

            var newVersionNumber = VersionNumber.Create(2, "newhash");
            var version          = new GlobalVersion
            {
                Hash    = "hash",
                Version = newVersionNumber
            };
            var versions = new Dictionary <string, GlobalVersion>
            {
                ["App-Service1"] = new GlobalVersion {
                    Version = newVersionNumber
                }
            };

            // w
            _appManifestHandler.SetGeneralInfo(appManifest, versions, version);

            // t
            var service1 = appManifest.ServiceManifestImports.Single(
                x => x.ServiceManifestRef.ServiceManifestName.Equals("Service1"));

            service1.ServiceManifestRef.ServiceManifestVersion.Should().Be("2-newhash");

            var service2 = appManifest.ServiceManifestImports.Single(
                x => x.ServiceManifestRef.ServiceManifestName.Equals("Service2"));

            service2.ServiceManifestRef.ServiceManifestVersion.Should().Be("1-hash");
        }
 public ManifestSigningDialog(DeployManifest deployManifest, ApplicationManifest appManifest)
 {
     m_DeployManifest = deployManifest;
     m_AppManifest    = appManifest;
     InitializeComponent();
     if (!string.IsNullOrEmpty(Settings.Default.LastSelectedCertificate) &&
         File.Exists(Settings.Default.LastSelectedCertificate))
     {
         m_PathTextBox.Text = Settings.Default.LastSelectedCertificate;
     }
 }
Exemplo n.º 24
0
        private DeployManifest CreateDeployManifest(ApplicationManifest applicationManifest, string applicationManifestPath,
                                                    string applicationManifestName, string url, string entryPointFilePath)
        {
            DeployManifest manifest = new DeployManifest(TargetFramework);

            if (!string.IsNullOrWhiteSpace(url))
            {
                manifest.DeploymentUrl = url;
            }

            manifest.MapFileExtensions      = true;
            manifest.Publisher              = Publisher;
            manifest.Product                = GetProductName(entryPointFilePath);
            manifest.TrustUrlParameters     = UrlParameters;
            manifest.Install                = Install;
            manifest.MinimumRequiredVersion = MinimumRequiredVersion;
            manifest.CreateDesktopShortcut  = CreateDesktopShortcut;

            if (RequireLatestVersion)
            {
                manifest.MinimumRequiredVersion = Version;
            }
            if (AutoUpdate && Install)
            {
                manifest.UpdateEnabled = true;
                manifest.UpdateMode    = UpdateMode.Foreground;
            }


            AssemblyReference assembly = new AssemblyReference(applicationManifestPath);
            AssemblyIdentity  identity = new AssemblyIdentity(applicationManifest.AssemblyIdentity);

            if (UseConfigName)
            {
                identity.Name = string.Format(CultureInfo.InvariantCulture, "{0}_{1}.app", Path.GetFileNameWithoutExtension(identity.Name), this.ConfigName);
            }
            else
            {
                identity.Name = string.Format(CultureInfo.InvariantCulture, "{0}.app", Path.GetFileNameWithoutExtension(identity.Name));
            }

            identity.Type = string.Empty;

            manifest.AssemblyIdentity = identity;
            manifest.AssemblyReferences.Add(assembly);
            manifest.EntryPoint = assembly;
            manifest.ResolveFiles();
            manifest.UpdateFileInfo();
            assembly.TargetPath = applicationManifestName;

            manifest.ResolveFiles();
            manifest.UpdateFileInfo();
            return(manifest);
        }
        /// <summary>
        /// Loads specified app manifest and populates the manifest variable
        /// </summary>
        /// <param name="assemManifestPath">Path to the app manifest to load</param>
        /// <returns>Application manifest reference</returns>
        public static ApplicationManifest LoadAppManifest(string assemManifestPath)
        {
            Manifest            manifest    = ManifestReader.ReadManifest(assemManifestPath, false);
            ApplicationManifest appManifest = manifest as ApplicationManifest;

            if (appManifest == null)
            {
                throw new FileNotFoundException("Unable to open referenced application manifest", assemManifestPath);
            }

            return(appManifest);
        }
Exemplo n.º 26
0
 public static void ListCurrentLinks(string appFolder, ApplicationManifest manifest)
 {
     if (manifest.LinkedFolders.Any())
     {
         Console.WriteLine("  Links for " + appFolder);
         manifest.LinkedFolders.Each(x => { Console.WriteLine("    " + x); });
     }
     else
     {
         Console.WriteLine("  No package links for " + appFolder);
     }
 }
Exemplo n.º 27
0
        protected override void beforeEach()
        {
            theInput = new LinkInput
            {
                PackageFolder = "package",
                AppFolder     = "app",
            };

            appManifest = new ApplicationManifest();
            pakManifest = new PackageManifest();
            Services.PartialMockTheClassUnderTest();
        }
Exemplo n.º 28
0
        /// <summary>
        /// Adds manifest references - a public method that calls into private recursive method
        /// that updates file and assembly references.
        /// </summary>
        /// <param name="manifest">Manifest whose references are to be updated</param>
        /// <param name="addDeploy">Specifies is '.deploy' should be appended</param>
        /// <param name="fromDirectory">Directory at which to begin the recursive search</param>
        /// <param name="filesToIgnore">Files that should not be included in the manifest</param>
        /// <param name="lockedFileReporter">Delegate via which locked files will be reported</param>
        /// <param name="sender">Sender</param>
        /// <param name="updateProgress">UpdateProgress event handler</param>
        /// <param name="overwrite">Overwrite event handler</param>
        /// <param name="errors">List of errors</param>
        public static void AddReferences(ApplicationManifest manifest,
                                         bool addDeploy,
                                         string fromDirectory, List <string> filesToIgnore,
                                         LockedFileReporter lockedFileReporter, object sender, UpdateProgressEventHandler updateProgress, OverwriteEventHandler overwrite, ArrayList errors)
        {
            if ((manifest == null) || (fromDirectory == null))
            {
                return;
            }

            // Strip a leading .\ from the path, if present
            if ((fromDirectory.Length >= 2) && fromDirectory.Substring(0, 2) == ".\\")
            {
                fromDirectory = fromDirectory.Substring(2);
            }

            // If stripping a leading .\ yields an empty string, use "."
            if (fromDirectory == "")
            {
                fromDirectory = ".";
            }

            // Append a trailing \ if necessary
            if (fromDirectory.LastIndexOf('\\') != fromDirectory.Length - 1)
            {
                fromDirectory += '\\';
            }

            // Add application manifest file to the ignore list
            string manifestName = (manifest.AssemblyIdentity.Name + ".manifest").ToLower();

            filesToIgnore.Add(manifestName);

            // We need to add the full path as well since the addDeploy
            // method is using the full filename for comparison.
            filesToIgnore.Add(manifest.SourcePath + manifestName);

            if (addDeploy)
            {
                filesToIgnore.Add(manifestName + ".deploy");
                filesToIgnore.Add(manifest.SourcePath + manifestName + ".deploy");
            }

            // Set the source path for the new references
            manifest.SourcePath = fromDirectory;

            updateProgress?.Invoke(sender, new UpdateProgressEventArgs(Action.Begin, ""));

            // Recursively search fromDirectory to get new references
            AddReferences(manifest, addDeploy, fromDirectory, fromDirectory, "", filesToIgnore, lockedFileReporter, sender, updateProgress, overwrite, errors);

            updateProgress?.Invoke(sender, new UpdateProgressEventArgs(Action.SearchComplete, ""));
        }
Exemplo n.º 29
0
        private void updateManifest(LinkInput input, FileSystem fileSystem, ApplicationManifest manifest)
        {
            if (input.RemoveFlag)
            {
                remove(input, manifest);
            }
            else
            {
                add(fileSystem, input, manifest);
            }

            persist(input, manifest, fileSystem);
        }
Exemplo n.º 30
0
        /// <summary>
        /// This encapsulates the reference-updating methods, for use by a
        /// background thread.
        /// </summary>
        /// <param name="manifest">ApplicationManifest object</param>
        /// <param name="addDeploy">Indicates if we are adding .deploy extension.</param>
        /// <param name="fromDirectory">Directory from which to obtain references</param>
        /// <param name="filesToIgnore">List of files to ignore.</param>
        /// <param name="sender">Not used</param>
        /// <param name="updateProgress">Not used</param>
        public static void AddAndUpdateReferences(ApplicationManifest manifest, bool addDeploy, string fromDirectory,
                                                  List <string> filesToIgnore, object sender, UpdateProgressEventHandler updateProgress, OverwriteEventHandler overwrite, string targetFrameworkVersion)
        {
            ArrayList errors = new ArrayList();

            Utilities.AppMan.AddReferences(manifest, addDeploy, fromDirectory, filesToIgnore, null, sender, updateProgress, overwrite, errors);

            Utilities.AppMan.SetSpecialFiles(manifest);

            Utilities.AppMan.UpdateReferenceInfo(manifest, fromDirectory, sender, updateProgress, targetFrameworkVersion);

            updateProgress?.Invoke(sender, new UpdateProgressEventArgs(Action.Complete, "", errors));
        }