private void FixupEntryPoint()
 {
     if (this.entryPoint == null)
     {
         this.entryPoint = base.AssemblyReferences.Find(this.entryPointIdentity);
     }
 }
 internal AssemblyReferenceCollection(AssemblyReference[] array)
 {
     if (array != null)
     {
         this.list.AddRange(array);
     }
 }
 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;
 }
        protected internal AssemblyReference AddAssemblyFromItem(ITaskItem item)
        {
            AssemblyReferenceType managedAssembly;
            AssemblyReference reference;
            if (this.IsEmbedInteropEnabledForAssembly(item))
            {
                return null;
            }
            switch (this.GetItemAssemblyType(item))
            {
                case AssemblyType.Managed:
                    managedAssembly = AssemblyReferenceType.ManagedAssembly;
                    break;

                case AssemblyType.Native:
                    managedAssembly = AssemblyReferenceType.NativeAssembly;
                    break;

                case AssemblyType.Satellite:
                    managedAssembly = AssemblyReferenceType.ManagedAssembly;
                    break;

                default:
                    managedAssembly = AssemblyReferenceType.Unspecified;
                    break;
            }
            if (this.GetItemDependencyType(item) == DependencyType.Install)
            {
                reference = this.manifest.AssemblyReferences.Add(item.ItemSpec);
                this.SetItemAttributes(item, reference);
            }
            else
            {
                AssemblyIdentity identity = AssemblyIdentity.FromAssemblyName(item.ItemSpec);
                if (identity.IsStrongName)
                {
                    reference = new AssemblyReference {
                        AssemblyIdentity = identity
                    };
                }
                else
                {
                    reference = new AssemblyReference(item.ItemSpec);
                }
                this.manifest.AssemblyReferences.Add(reference);
                reference.IsPrerequisite = true;
            }
            reference.ReferenceType = managedAssembly;
            if (string.Equals(item.GetMetadata("IsPrimary"), "true", StringComparison.Ordinal))
            {
                reference.IsPrimary = true;
            }
            return reference;
        }
 private void FixupClrVersion()
 {
     AssemblyReference assembly = base.AssemblyReferences.Find("Microsoft.Windows.CommonLanguageRuntime");
     if (assembly == null)
     {
         assembly = new AssemblyReference {
             IsPrerequisite = true
         };
         base.AssemblyReferences.Add(assembly);
     }
     if ((assembly.AssemblyIdentity == null) || string.IsNullOrEmpty(assembly.AssemblyIdentity.Version))
     {
         assembly.AssemblyIdentity = new AssemblyIdentity("Microsoft.Windows.CommonLanguageRuntime", Util.GetClrVersion(this.targetFrameworkVersion));
     }
 }
Exemplo n.º 6
0
        private void ValidateReferenceForPartialTrust(AssemblyReference assembly, TrustInfo trustInfo)
        {
            if (trustInfo.IsFullTrust)
            {
                return;
            }
            string path = assembly.ResolvedPath;
            AssemblyAttributeFlags flags = new AssemblyAttributeFlags(path);

            // if it's targeting v2.0 CLR then use the old logic to check for partial trust callers.
            if (Util.CompareFrameworkVersions(this.TargetFrameworkVersion, Constants.TargetFrameworkVersion35) <= 0)
            {
                if (assembly.IsPrimary && flags.IsSigned &&
                    !flags.HasAllowPartiallyTrustedCallersAttribute)
                {
                    OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", Path.GetFileNameWithoutExtension(path));
                }
            }
            else
            {
                if (assembly.AssemblyIdentity != null && assembly.AssemblyIdentity.IsInFramework(Constants.DotNetFrameworkIdentifier, TargetFrameworkVersion))
                {
                    // if the binary is targeting v4.0 and it has the transparent attribute then we may allow partially trusted callers.
                    if (assembly.IsPrimary &&
                        !(flags.HasAllowPartiallyTrustedCallersAttribute || flags.HasSecurityTransparentAttribute))
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", Path.GetFileNameWithoutExtension(path));
                    }
                }
                else
                {
                    // if the binary is targeting v4.0 and it has the transparent attribute then we may allow partially trusted callers.
                    if (assembly.IsPrimary && flags.IsSigned &&
                        !(flags.HasAllowPartiallyTrustedCallersAttribute || flags.HasSecurityTransparentAttribute))
                    {
                        OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", Path.GetFileNameWithoutExtension(path));
                    }
                }
            }

            if (flags.HasPrimaryInteropAssemblyAttribute || flags.HasImportedFromTypeLibAttribute)
            {
                OutputMessages.AddWarningMessage("GenerateManifest.UnmanagedCodePermission", Path.GetFileNameWithoutExtension(path));
            }
        }
Exemplo n.º 7
0
        // Determines whether the platform of the specified assembly reference is mismatched with the applicaion's platform.
        private bool IsMismatchedPlatform(AssemblyReference assembly)
        {
            // Never flag the "Microsoft.CommonLanguageRuntime" dependency as a mismatch...
            if (assembly.IsVirtual)
            {
                return(false);
            }
            // Can't tell anything if either of these are not resolved...
            if (AssemblyIdentity == null || assembly.AssemblyIdentity == null)
            {
                return(false);
            }

            if (AssemblyIdentity.IsNeutralPlatform)
            {
                // If component is a native assembly then it is non-platform neutral by definition, so always flag as a mismatch...
                if (assembly.ReferenceType == AssemblyReferenceType.NativeAssembly)
                {
                    return(true);
                }
                // Otherwise flag component as a mismatch only if it's not also platform neutral...
                return(!assembly.AssemblyIdentity.IsNeutralPlatform);
            }
            else
            {
                // We want the application platform for the entry point to always match the setting for the whole application,
                // but the dependencies do not necessarily have to match...
                if (assembly != EntryPoint)
                {
                    // If application IS NOT platform neutral but the component is, then component shouldn't be flagged as a mismatch...
                    if (assembly.AssemblyIdentity.IsNeutralPlatform)
                    {
                        return(false);
                    }
                }

                // Either we are looking at the entry point assembly or the assembly is not platform neutral.
                // We need to compare the application's platform to the component's platform,
                // if they don't match then flag component as a mismatch...
                return(!String.Equals(AssemblyIdentity.ProcessorArchitecture, assembly.AssemblyIdentity.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase));
            }
        }
 private bool IsMismatchedPlatform(AssemblyReference assembly)
 {
     if (assembly.IsVirtual)
     {
         return(false);
     }
     if ((this.AssemblyIdentity == null) || (assembly.AssemblyIdentity == null))
     {
         return(false);
     }
     if (this.AssemblyIdentity.IsNeutralPlatform)
     {
         return((assembly.ReferenceType == AssemblyReferenceType.NativeAssembly) || !assembly.AssemblyIdentity.IsNeutralPlatform);
     }
     if ((assembly != this.EntryPoint) && assembly.AssemblyIdentity.IsNeutralPlatform)
     {
         return(false);
     }
     return(!string.Equals(this.AssemblyIdentity.ProcessorArchitecture, assembly.AssemblyIdentity.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase));
 }
 private bool IsMismatchedPlatform(AssemblyReference assembly)
 {
     if (assembly.IsVirtual)
     {
         return false;
     }
     if ((this.AssemblyIdentity == null) || (assembly.AssemblyIdentity == null))
     {
         return false;
     }
     if (this.AssemblyIdentity.IsNeutralPlatform)
     {
         return ((assembly.ReferenceType == AssemblyReferenceType.NativeAssembly) || !assembly.AssemblyIdentity.IsNeutralPlatform);
     }
     if ((assembly != this.EntryPoint) && assembly.AssemblyIdentity.IsNeutralPlatform)
     {
         return false;
     }
     return !string.Equals(this.AssemblyIdentity.ProcessorArchitecture, assembly.AssemblyIdentity.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase);
 }
 private bool ResolveAssembly(AssemblyReference a, string[] searchPaths)
 {
     if (a == null)
     {
         return(false);
     }
     a.ResolvedPath = this.ResolvePath(a.SourcePath, searchPaths);
     if (!string.IsNullOrEmpty(a.ResolvedPath))
     {
         return(true);
     }
     if (a.AssemblyIdentity != null)
     {
         a.ResolvedPath = a.AssemblyIdentity.Resolve(searchPaths);
         if (!string.IsNullOrEmpty(a.ResolvedPath))
         {
             return(true);
         }
     }
     a.ResolvedPath = this.ResolvePath(a.TargetPath, searchPaths);
     return(!string.IsNullOrEmpty(a.ResolvedPath));
 }
 private bool ResolveAssembly(AssemblyReference a, string[] searchPaths)
 {
     if (a == null)
     {
         return false;
     }
     a.ResolvedPath = this.ResolvePath(a.SourcePath, searchPaths);
     if (!string.IsNullOrEmpty(a.ResolvedPath))
     {
         return true;
     }
     if (a.AssemblyIdentity != null)
     {
         a.ResolvedPath = a.AssemblyIdentity.Resolve(searchPaths);
         if (!string.IsNullOrEmpty(a.ResolvedPath))
         {
             return true;
         }
     }
     a.ResolvedPath = this.ResolvePath(a.TargetPath, searchPaths);
     return !string.IsNullOrEmpty(a.ResolvedPath);
 }
 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);
     }
 }
        private bool AddClickOnceFiles(ApplicationManifest manifest)
        {
            int t1 = Environment.TickCount;

            if (ConfigFile != null && !String.IsNullOrEmpty(ConfigFile.ItemSpec))
                manifest.ConfigFile = FindFileFromItem(ConfigFile).TargetPath;

            if (IconFile != null && !String.IsNullOrEmpty(IconFile.ItemSpec))
                manifest.IconFile = FindFileFromItem(IconFile).TargetPath;

            if (TrustInfoFile != null && !String.IsNullOrEmpty(TrustInfoFile.ItemSpec))
            {
                manifest.TrustInfo = new TrustInfo();
                manifest.TrustInfo.Read(TrustInfoFile.ItemSpec);
            }

            if (manifest.TrustInfo == null)
                manifest.TrustInfo = new TrustInfo();

            if (OSVersion != null)
            {
                manifest.OSVersion = _osVersion;
            }

            if (ClrVersion != null)
            {
                AssemblyReference CLRPlatformAssembly = manifest.AssemblyReferences.Find(Constants.CLRPlatformAssemblyName);
                if (CLRPlatformAssembly == null)
                {
                    CLRPlatformAssembly = new AssemblyReference();
                    CLRPlatformAssembly.IsPrerequisite = true;
                    manifest.AssemblyReferences.Add(CLRPlatformAssembly);
                }
                CLRPlatformAssembly.AssemblyIdentity = new AssemblyIdentity(Constants.CLRPlatformAssemblyName, ClrVersion);
            }

            if (Util.CompareFrameworkVersions(TargetFrameworkVersion, Constants.TargetFrameworkVersion30) == 0)
            {
                EnsureAssemblyReferenceExists(manifest, CreateAssemblyIdentity(Constants.NET30AssemblyIdentity));
            }
            else if (Util.CompareFrameworkVersions(TargetFrameworkVersion, Constants.TargetFrameworkVersion35) == 0)
            {
                EnsureAssemblyReferenceExists(manifest, CreateAssemblyIdentity(Constants.NET30AssemblyIdentity));
                EnsureAssemblyReferenceExists(manifest, CreateAssemblyIdentity(Constants.NET35AssemblyIdentity));

                if ((!String.IsNullOrEmpty(TargetFrameworkSubset) && TargetFrameworkSubset.Equals(Constants.ClientFrameworkSubset, StringComparison.OrdinalIgnoreCase)) ||
            (!String.IsNullOrEmpty(TargetFrameworkProfile) && TargetFrameworkProfile.Equals(Constants.ClientFrameworkSubset, StringComparison.OrdinalIgnoreCase)))
                {
                    EnsureAssemblyReferenceExists(manifest, CreateAssemblyIdentity(Constants.NET35ClientAssemblyIdentity));
                }
                else if (RequiresMinimumFramework35SP1)
                {
                    EnsureAssemblyReferenceExists(manifest, CreateAssemblyIdentity(Constants.NET35SP1AssemblyIdentity));
                }
            }

            Util.WriteLog(String.Format(CultureInfo.CurrentCulture, "GenerateApplicationManifest.AddClickOnceFiles t={0}", Environment.TickCount - t1));
            return true;
        }
Exemplo n.º 14
0
 // Make sure we have a CLR dependency, add it if not...
 private void FixupClrVersion()
 {
     AssemblyReference CLRPlatformAssembly = AssemblyReferences.Find(Constants.CLRPlatformAssemblyName);
     if (CLRPlatformAssembly == null)
     {
         CLRPlatformAssembly = new AssemblyReference();
         CLRPlatformAssembly.IsPrerequisite = true;
         AssemblyReferences.Add(CLRPlatformAssembly);
     }
     if (CLRPlatformAssembly.AssemblyIdentity == null || String.IsNullOrEmpty(CLRPlatformAssembly.AssemblyIdentity.Version))
     {
         CLRPlatformAssembly.AssemblyIdentity = new AssemblyIdentity(Constants.CLRPlatformAssemblyName, Util.GetClrVersion(_targetFrameworkVersion));
     }
 }
 public AssemblyReference Add(AssemblyReference assembly)
 {
     this.list.Add(assembly);
     return(assembly);
 }
Exemplo n.º 16
0
 protected internal AssemblyReference AddAssemblyNameFromItem(ITaskItem item, AssemblyReferenceType referenceType)
 {
     AssemblyReference assembly = new AssemblyReference();
     assembly.AssemblyIdentity = AssemblyIdentity.FromAssemblyName(item.ItemSpec);
     assembly.ReferenceType = referenceType;
     _manifest.AssemblyReferences.Add(assembly);
     string hintPath = item.GetMetadata("HintPath");
     if (!String.IsNullOrEmpty(hintPath))
         assembly.SourcePath = hintPath;
     SetItemAttributes(item, assembly);
     return assembly;
 }
		public void Remove (AssemblyReference assemblyReference)
		{
			list.Remove (assemblyReference);
		}
 protected internal AssemblyReference AddAssemblyNameFromItem(ITaskItem item, AssemblyReferenceType referenceType)
 {
     AssemblyReference assembly = new AssemblyReference {
         AssemblyIdentity = AssemblyIdentity.FromAssemblyName(item.ItemSpec),
         ReferenceType = referenceType
     };
     this.manifest.AssemblyReferences.Add(assembly);
     string metadata = item.GetMetadata("HintPath");
     if (!string.IsNullOrEmpty(metadata))
     {
         assembly.SourcePath = metadata;
     }
     this.SetItemAttributes(item, assembly);
     return assembly;
 }
Exemplo n.º 19
0
        private void UpdateAssemblyReference(AssemblyReference a, string targetFrameworkVersion)
        {
            if (a.IsVirtual)
                return;

            if (a.AssemblyIdentity == null)
                switch (a.ReferenceType)
                {
                    case AssemblyReferenceType.ClickOnceManifest:
                        a.AssemblyIdentity = AssemblyIdentity.FromManifest(a.ResolvedPath);
                        break;
                    case AssemblyReferenceType.ManagedAssembly:
                        a.AssemblyIdentity = AssemblyIdentity.FromManagedAssembly(a.ResolvedPath);
                        break;
                    case AssemblyReferenceType.NativeAssembly:
                        a.AssemblyIdentity = AssemblyIdentity.FromNativeAssembly(a.ResolvedPath);
                        break;
                    default:
                        a.AssemblyIdentity = AssemblyIdentity.FromFile(a.ResolvedPath);
                        break;
                }
            if (!a.IsPrerequisite)
                UpdateFileReference(a, targetFrameworkVersion);

            // If unspecified assembly type then let's figure out what it actually is...
            if (a.ReferenceType == AssemblyReferenceType.Unspecified)
            {
                // a ClickOnce deployment manifest can only refer to a ClickOnce application manifest...
                if (this is DeployManifest)
                {
                    a.ReferenceType = AssemblyReferenceType.ClickOnceManifest;
                }
                // otherwise it can only be either a managed or a native assembly, but we can only tell if we have the path...
                else if (!String.IsNullOrEmpty(a.ResolvedPath))
                {
                    if (PathUtil.IsNativeAssembly(a.ResolvedPath))
                        a.ReferenceType = AssemblyReferenceType.NativeAssembly;
                    else
                        a.ReferenceType = AssemblyReferenceType.ManagedAssembly;
                }
                // there's one other way we can tell, Type="win32" references are always native...
                else if (a.AssemblyIdentity != null && String.Equals(a.AssemblyIdentity.Type, "win32", StringComparison.OrdinalIgnoreCase))
                {
                    a.ReferenceType = AssemblyReferenceType.NativeAssembly;
                }
            }
        }
Exemplo n.º 20
0
        // Determines whether the platform of the specified assembly reference is mismatched with the applicaion's platform.
        private bool IsMismatchedPlatform(AssemblyReference assembly)
        {
            // Never flag the "Microsoft.CommonLanguageRuntime" dependency as a mismatch...
            if (assembly.IsVirtual)
                return false;
            // Can't tell anything if either of these are not resolved...
            if (AssemblyIdentity == null || assembly.AssemblyIdentity == null)
                return false;

            if (AssemblyIdentity.IsNeutralPlatform)
            {
                // If component is a native assembly then it is non-platform neutral by definition, so always flag as a mismatch...
                if (assembly.ReferenceType == AssemblyReferenceType.NativeAssembly)
                    return true;
                // Otherwise flag component as a mismatch only if it's not also platform neutral...
                return !assembly.AssemblyIdentity.IsNeutralPlatform;
            }
            else
            {
                // We want the application platform for the entry point to always match the setting for the whole application,
                // but the dependencies do not necessarily have to match...
                if (assembly != EntryPoint)
                {
                    // If application IS NOT platform neutral but the component is, then component shouldn't be flagged as a mismatch...
                    if (assembly.AssemblyIdentity.IsNeutralPlatform)
                        return false;
                }

                // Either we are looking at the entry point assembly or the assembly is not platform neutral. 
                // We need to compare the application's platform to the component's platform,
                // if they don't match then flag component as a mismatch...
                return !String.Equals(AssemblyIdentity.ProcessorArchitecture, assembly.AssemblyIdentity.ProcessorArchitecture, StringComparison.OrdinalIgnoreCase);
            }
        }
Exemplo n.º 21
0
 internal override void OnAfterLoad()
 {
     base.OnAfterLoad();
     if (_entryPoint == null && AssemblyReferences != null && AssemblyReferences.Count > 0)
     {
         _entryPoint = AssemblyReferences[0];
         _entryPoint.ReferenceType = AssemblyReferenceType.ClickOnceManifest;
     }
 }
		public AssemblyReference Add (AssemblyReference assembly)
		{
			list.Add (assembly);
			return assembly;
		}
 internal AssemblyReferenceCollection(AssemblyReference[] array)
 {
     if (array == null)
         return;
     _list.AddRange(array);
 }
		public AssemblyReference Add (string path)
		{
			AssemblyReference ar = new AssemblyReference (path);
			list.Add (ar);
			return ar;
		}
Exemplo n.º 25
0
        private void ValidateReferenceForPartialTrust(AssemblyReference assembly, TrustInfo trustInfo)
        {
            if (trustInfo.IsFullTrust)
                return;
            string path = assembly.ResolvedPath;
            AssemblyAttributeFlags flags = new AssemblyAttributeFlags(path);

            // if it's targeting v2.0 CLR then use the old logic to check for partial trust callers.
            if (Util.CompareFrameworkVersions(this.TargetFrameworkVersion, Constants.TargetFrameworkVersion35) <= 0)
            {
                if (assembly.IsPrimary && flags.IsSigned
                    && !flags.HasAllowPartiallyTrustedCallersAttribute)
                    OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", Path.GetFileNameWithoutExtension(path));
            }
            else
            {
                if (assembly.AssemblyIdentity != null && assembly.AssemblyIdentity.IsInFramework(Constants.DotNetFrameworkIdentifier, TargetFrameworkVersion))
                {
                    // if the binary is targeting v4.0 and it has the transparent attribute then we may allow partially trusted callers.
                    if (assembly.IsPrimary
                        && !(flags.HasAllowPartiallyTrustedCallersAttribute || flags.HasSecurityTransparentAttribute))
                        OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", Path.GetFileNameWithoutExtension(path));
                }
                else
                {
                    // if the binary is targeting v4.0 and it has the transparent attribute then we may allow partially trusted callers.
                    if (assembly.IsPrimary && flags.IsSigned
                        && !(flags.HasAllowPartiallyTrustedCallersAttribute || flags.HasSecurityTransparentAttribute))
                        OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", Path.GetFileNameWithoutExtension(path));
                }
            }

            if (flags.HasPrimaryInteropAssemblyAttribute || flags.HasImportedFromTypeLibAttribute)
                OutputMessages.AddWarningMessage("GenerateManifest.UnmanagedCodePermission", Path.GetFileNameWithoutExtension(path));
        }
 internal override void OnAfterLoad()
 {
     base.OnAfterLoad();
     if (((this.entryPoint == null) && (base.AssemblyReferences != null)) && (base.AssemblyReferences.Count > 0))
     {
         this.entryPoint = base.AssemblyReferences[0];
         this.entryPoint.ReferenceType = AssemblyReferenceType.ClickOnceManifest;
     }
 }
 private void ValidateReferenceForPartialTrust(AssemblyReference assembly, Microsoft.Build.Tasks.Deployment.ManifestUtilities.TrustInfo trustInfo)
 {
     if (!trustInfo.IsFullTrust)
     {
         string resolvedPath = assembly.ResolvedPath;
         AssemblyAttributeFlags flags = new AssemblyAttributeFlags(resolvedPath);
         if (Util.CompareFrameworkVersions(this.TargetFrameworkVersion, "v3.5") <= 0)
         {
             if ((assembly.IsPrimary && flags.IsSigned) && !flags.HasAllowPartiallyTrustedCallersAttribute)
             {
                 base.OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", new string[] { Path.GetFileNameWithoutExtension(resolvedPath) });
             }
         }
         else if ((assembly.AssemblyIdentity != null) && assembly.AssemblyIdentity.IsFrameworkAssembly)
         {
             if ((assembly.IsPrimary && !flags.HasAllowPartiallyTrustedCallersAttribute) && !flags.HasSecurityTransparentAttribute)
             {
                 base.OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", new string[] { Path.GetFileNameWithoutExtension(resolvedPath) });
             }
         }
         else if ((assembly.IsPrimary && flags.IsSigned) && (!flags.HasAllowPartiallyTrustedCallersAttribute && !flags.HasSecurityTransparentAttribute))
         {
             base.OutputMessages.AddWarningMessage("GenerateManifest.AllowPartiallyTrustedCallers", new string[] { Path.GetFileNameWithoutExtension(resolvedPath) });
         }
         if (flags.HasPrimaryInteropAssemblyAttribute || flags.HasImportedFromTypeLibAttribute)
         {
             base.OutputMessages.AddWarningMessage("GenerateManifest.UnmanagedCodePermission", new string[] { Path.GetFileNameWithoutExtension(resolvedPath) });
         }
     }
 }
Exemplo n.º 28
0
        protected internal AssemblyReference AddAssemblyFromItem(ITaskItem item)
        {
            // if the assembly is a no-pia assembly and embed interop is turned on, then we don't write it to the manifest.
            if (IsEmbedInteropEnabledForAssembly(item))
                return null;

            AssemblyReferenceType referenceType;
            AssemblyType assemblyType = GetItemAssemblyType(item);
            switch (assemblyType)
            {
                case AssemblyType.Managed:
                    referenceType = AssemblyReferenceType.ManagedAssembly;
                    break;
                case AssemblyType.Native:
                    referenceType = AssemblyReferenceType.NativeAssembly;
                    break;
                case AssemblyType.Satellite:
                    referenceType = AssemblyReferenceType.ManagedAssembly;
                    break;
                default:
                    referenceType = AssemblyReferenceType.Unspecified;
                    break;
            }

            DependencyType dependencyType = GetItemDependencyType(item);
            AssemblyReference assembly;
            if (dependencyType == DependencyType.Install)
            {
                assembly = _manifest.AssemblyReferences.Add(item.ItemSpec);
                SetItemAttributes(item, assembly);
            }
            else
            {
                AssemblyIdentity identity = AssemblyIdentity.FromAssemblyName(item.ItemSpec);
                // If we interpreted the item as a strong name, then treat it as a Fusion display name...
                if (identity.IsStrongName)
                {
                    assembly = new AssemblyReference();
                    assembly.AssemblyIdentity = identity;
                }
                else // otherwise treat it as a file path...
                {
                    assembly = new AssemblyReference(item.ItemSpec);
                }
                _manifest.AssemblyReferences.Add(assembly);
                assembly.IsPrerequisite = true;
            }

            assembly.ReferenceType = referenceType;
            string isPrimary = item.GetMetadata(ItemMetadataNames.isPrimary);
            if (string.Equals(isPrimary, "true", StringComparison.Ordinal))
            {
                assembly.IsPrimary = true;
            }

            return assembly;
        }
Exemplo n.º 29
0
 private void FixupEntryPoint()
 {
     if (_entryPoint == null)
         _entryPoint = AssemblyReferences.Find(_entryPointIdentity);
 }
 public void Remove(AssemblyReference assemblyReference)
 {
     this.list.Remove(assemblyReference);
 }
        private void UpdateAssemblyReference(AssemblyReference a)
        {
            if (a.IsVirtual)
            {
                return;
            }
            if (a.AssemblyIdentity == null)
            {
                switch (a.ReferenceType)
                {
                    case AssemblyReferenceType.ClickOnceManifest:
                        a.AssemblyIdentity = Microsoft.Build.Tasks.Deployment.ManifestUtilities.AssemblyIdentity.FromManifest(a.ResolvedPath);
                        goto Label_0078;

                    case AssemblyReferenceType.ManagedAssembly:
                        a.AssemblyIdentity = Microsoft.Build.Tasks.Deployment.ManifestUtilities.AssemblyIdentity.FromManagedAssembly(a.ResolvedPath);
                        goto Label_0078;

                    case AssemblyReferenceType.NativeAssembly:
                        a.AssemblyIdentity = Microsoft.Build.Tasks.Deployment.ManifestUtilities.AssemblyIdentity.FromNativeAssembly(a.ResolvedPath);
                        goto Label_0078;
                }
                a.AssemblyIdentity = Microsoft.Build.Tasks.Deployment.ManifestUtilities.AssemblyIdentity.FromFile(a.ResolvedPath);
            }
        Label_0078:
            if (!a.IsPrerequisite)
            {
                UpdateFileReference(a);
            }
            if (a.ReferenceType == AssemblyReferenceType.Unspecified)
            {
                if (this is DeployManifest)
                {
                    a.ReferenceType = AssemblyReferenceType.ClickOnceManifest;
                }
                else if (!string.IsNullOrEmpty(a.ResolvedPath))
                {
                    if (PathUtil.IsNativeAssembly(a.ResolvedPath))
                    {
                        a.ReferenceType = AssemblyReferenceType.NativeAssembly;
                    }
                    else
                    {
                        a.ReferenceType = AssemblyReferenceType.ManagedAssembly;
                    }
                }
                else if ((a.AssemblyIdentity != null) && string.Equals(a.AssemblyIdentity.Type, "win32", StringComparison.OrdinalIgnoreCase))
                {
                    a.ReferenceType = AssemblyReferenceType.NativeAssembly;
                }
            }
        }