Ejemplo n.º 1
0
        private void ValidateReferencesForClickOnceApplication()
        {
            int  tickCount = Environment.TickCount;
            bool flag      = !this.TrustInfo.IsFullTrust;
            Dictionary <string, NGen <bool> > dictionary = new Dictionary <string, NGen <bool> >();

            foreach (AssemblyReference reference in base.AssemblyReferences)
            {
                if ((flag && (reference != this.EntryPoint)) && !string.IsNullOrEmpty(reference.ResolvedPath))
                {
                    this.ValidateReferenceForPartialTrust(reference, this.TrustInfo);
                }
                if (!reference.IsPrerequisite && !string.IsNullOrEmpty(reference.TargetPath))
                {
                    if ((this.maxTargetPath > 0) && (reference.TargetPath.Length > this.maxTargetPath))
                    {
                        base.OutputMessages.AddWarningMessage("GenerateManifest.TargetPathTooLong", new string[] { reference.ToString(), this.maxTargetPath.ToString(CultureInfo.CurrentCulture) });
                    }
                    string key = reference.TargetPath.ToLowerInvariant();
                    if (!dictionary.ContainsKey(key))
                    {
                        dictionary.Add(key, 0);
                    }
                    else if (dictionary[key] == 0)
                    {
                        base.OutputMessages.AddWarningMessage("GenerateManifest.DuplicateTargetPath", new string[] { reference.ToString() });
                        dictionary[key] = 1;
                    }
                }
                else if ((this.maxTargetPath > 0) && (reference.AssemblyIdentity.Name.Length > this.maxTargetPath))
                {
                    base.OutputMessages.AddWarningMessage("GenerateManifest.TargetPathTooLong", new string[] { reference.AssemblyIdentity.Name, this.maxTargetPath.ToString(CultureInfo.CurrentCulture) });
                }
                if ((reference.IsPrerequisite && !reference.AssemblyIdentity.IsStrongName) && !reference.IsVirtual)
                {
                    base.OutputMessages.AddErrorMessage("GenerateManifest.PrerequisiteNotSigned", new string[] { reference.ToString() });
                }
            }
            foreach (FileReference reference2 in base.FileReferences)
            {
                if (!string.IsNullOrEmpty(reference2.ResolvedPath) && PathUtil.IsAssembly(reference2.ResolvedPath))
                {
                    base.OutputMessages.AddWarningMessage("GenerateManifest.AssemblyAsFile", new string[] { reference2.ToString() });
                }
                if (!string.IsNullOrEmpty(reference2.TargetPath))
                {
                    if ((this.maxTargetPath > 0) && (reference2.TargetPath.Length > this.maxTargetPath))
                    {
                        base.OutputMessages.AddWarningMessage("GenerateManifest.TargetPathTooLong", new string[] { reference2.TargetPath, this.maxTargetPath.ToString(CultureInfo.CurrentCulture) });
                    }
                    string str2 = reference2.TargetPath.ToLowerInvariant();
                    if (!dictionary.ContainsKey(str2))
                    {
                        dictionary.Add(str2, 0);
                    }
                    else if (dictionary[str2] == 0)
                    {
                        base.OutputMessages.AddWarningMessage("GenerateManifest.DuplicateTargetPath", new string[] { reference2.TargetPath });
                        dictionary[str2] = 1;
                    }
                }
            }
            Util.WriteLog(string.Format(CultureInfo.CurrentCulture, "GenerateManifest.CheckManifestReferences t={0}", new object[] { Environment.TickCount - tickCount }));
        }
Ejemplo n.º 2
0
        private void ValidateReferencesForClickOnceApplication()
        {
            int  t1             = Environment.TickCount;
            bool isPartialTrust = !TrustInfo.IsFullTrust;
            Dictionary <string, NGen <bool> > targetPathList = new Dictionary <string, NGen <bool> >();

            foreach (AssemblyReference assembly in AssemblyReferences)
            {
                // Check all resolved dependencies for partial trust apps...
                if (isPartialTrust && (assembly != EntryPoint) && !String.IsNullOrEmpty(assembly.ResolvedPath))
                {
                    ValidateReferenceForPartialTrust(assembly, TrustInfo);
                }

                // Check TargetPath for all local dependencies, ignoring any Prerequisites
                if (!assembly.IsPrerequisite && !String.IsNullOrEmpty(assembly.TargetPath))
                {
                    // Check target path does not exceed maximum...
                    if (_maxTargetPath > 0 && assembly.TargetPath.Length > _maxTargetPath)
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.TargetPathTooLong", assembly.ToString(), _maxTargetPath.ToString(CultureInfo.CurrentCulture));
                    }

                    // Check for two or more items with the same TargetPath...
                    string key = assembly.TargetPath.ToLowerInvariant();
                    if (!targetPathList.ContainsKey(key))
                    {
                        targetPathList.Add(key, false);
                    }
                    else if (targetPathList[key] == false)
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.DuplicateTargetPath", assembly.ToString());
                        targetPathList[key] = true; // only warn once per path
                    }
                }
                else
                {
                    // Check assembly name does not exceed maximum...
                    if (_maxTargetPath > 0 && assembly.AssemblyIdentity.Name.Length > _maxTargetPath)
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.TargetPathTooLong", assembly.AssemblyIdentity.Name, _maxTargetPath.ToString(CultureInfo.CurrentCulture));
                    }
                }

                // Check that all prerequisites are strong named...
                if (assembly.IsPrerequisite && !assembly.AssemblyIdentity.IsStrongName && !assembly.IsVirtual)
                {
                    OutputMessages.AddErrorMessage("GenerateManifest.PrerequisiteNotSigned", assembly.ToString());
                }
            }
            foreach (FileReference file in FileReferences)
            {
                // Check that file is not an assembly...
                if (!String.IsNullOrEmpty(file.ResolvedPath) && PathUtil.IsAssembly(file.ResolvedPath))
                {
                    OutputMessages.AddWarningMessage("GenerateManifest.AssemblyAsFile", file.ToString());
                }

                if (!String.IsNullOrEmpty(file.TargetPath))
                {
                    // Check target path does not exceed maximum...
                    if (_maxTargetPath > 0 && file.TargetPath.Length > _maxTargetPath)
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.TargetPathTooLong", file.TargetPath, _maxTargetPath.ToString(CultureInfo.CurrentCulture));
                    }

                    // Check for two or more items with the same TargetPath...
                    string key = file.TargetPath.ToLowerInvariant();
                    if (!targetPathList.ContainsKey(key))
                    {
                        targetPathList.Add(key, false);
                    }
                    else if (targetPathList[key] == false)
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.DuplicateTargetPath", file.TargetPath);
                        targetPathList[key] = true; // only warn once per path
                    }
                }
            }
            Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "GenerateManifest.CheckManifestReferences t={0}", Environment.TickCount - t1));
        }