internal ReferenceTable(bool findDependencies, bool findSatellites, bool findSerializationAssemblies, bool findRelatedFiles, string[] searchPaths, string[] allowedAssemblyExtensions, string[] relatedFileExtensions, string[] candidateAssemblyFiles, string[] frameworkPaths, InstalledAssemblies installedAssemblies, System.Reflection.ProcessorArchitecture targetProcessorArchitecture, Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.DirectoryExists directoryExists, Microsoft.Build.Tasks.GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, OpenBaseKey openBaseKey, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, Version projectTargetFramework, FrameworkName targetFrameworkMoniker, TaskLoggingHelper log, string[] latestTargetFrameworkDirectories, bool copyLocalDependenciesWhenParentReferenceInGac, CheckIfAssemblyInGac checkIfAssemblyIsInGac)
 {
     this.log = log;
     this.findDependencies = findDependencies;
     this.findSatellites = findSatellites;
     this.findSerializationAssemblies = findSerializationAssemblies;
     this.findRelatedFiles = findRelatedFiles;
     this.frameworkPaths = frameworkPaths;
     this.allowedAssemblyExtensions = allowedAssemblyExtensions;
     this.relatedFileExtensions = relatedFileExtensions;
     this.installedAssemblies = installedAssemblies;
     this.targetProcessorArchitecture = targetProcessorArchitecture;
     this.fileExists = fileExists;
     this.directoryExists = directoryExists;
     this.getDirectories = getDirectories;
     this.getAssemblyName = getAssemblyName;
     this.getAssemblyMetadata = getAssemblyMetadata;
     this.getRuntimeVersion = getRuntimeVersion;
     this.projectTargetFramework = projectTargetFramework;
     this.targetedRuntimeVersion = targetedRuntimeVersion;
     this.openBaseKey = openBaseKey;
     this.targetFrameworkMoniker = targetFrameworkMoniker;
     this.latestTargetFrameworkDirectories = latestTargetFrameworkDirectories;
     this.copyLocalDependenciesWhenParentReferenceInGac = copyLocalDependenciesWhenParentReferenceInGac;
     this.checkIfAssemblyIsInGac = checkIfAssemblyIsInGac;
     this.compiledSearchPaths = AssemblyResolution.CompileSearchPaths(searchPaths, candidateAssemblyFiles, targetProcessorArchitecture, frameworkPaths, fileExists, getAssemblyName, getRegistrySubKeyNames, getRegistrySubKeyDefaultValue, openBaseKey, installedAssemblies, getRuntimeVersion, targetedRuntimeVersion);
 }
Пример #2
0
        internal bool ExecuteImpl(Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.FileCreate fileCreate, GetAttributes fileGetAttributes, SetAttributes fileSetAttributes, SetLastAccessTime fileSetLastAccessTime, SetLastWriteTime fileSetLastWriteTime)
        {
            DateTime touchDateTime;

            try
            {
                touchDateTime = this.GetTouchDateTime();
            }
            catch (FormatException exception)
            {
                base.Log.LogErrorWithCodeFromResources("Touch.TimeSyntaxIncorrect", new object[] { exception.Message });
                return(false);
            }
            bool             flag = true;
            ArrayList        list = new ArrayList();
            HashSet <string> set  = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (ITaskItem item in this.Files)
            {
                if (!set.Contains(item.ItemSpec))
                {
                    if (this.TouchFile(item.ItemSpec, touchDateTime, fileExists, fileCreate, fileGetAttributes, fileSetAttributes, fileSetLastAccessTime, fileSetLastWriteTime))
                    {
                        list.Add(item);
                    }
                    else
                    {
                        flag = false;
                    }
                    set.Add(item.ItemSpec);
                }
            }
            this.TouchedFiles = (ITaskItem[])list.ToArray(typeof(ITaskItem));
            return(flag);
        }
 protected Resolver(string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion, ProcessorArchitecture targetedProcessorArchitecture, bool compareProcessorArchitecture)
 {
     this.searchPathElement = searchPathElement;
     this.getAssemblyName = getAssemblyName;
     this.fileExists = fileExists;
     this.getRuntimeVersion = getRuntimeVersion;
     this.targetedRuntimeVersion = targetedRuntimeVesion;
     this.targetProcessorArchitecture = targetedProcessorArchitecture;
     this.compareProcessorArchitecture = compareProcessorArchitecture;
 }
 protected Resolver(string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion, ProcessorArchitecture targetedProcessorArchitecture, bool compareProcessorArchitecture)
 {
     this.searchPathElement            = searchPathElement;
     this.getAssemblyName              = getAssemblyName;
     this.fileExists                   = fileExists;
     this.getRuntimeVersion            = getRuntimeVersion;
     this.targetedRuntimeVersion       = targetedRuntimeVesion;
     this.targetProcessorArchitecture  = targetedProcessorArchitecture;
     this.compareProcessorArchitecture = compareProcessorArchitecture;
 }
        internal static string GeneratePathToTool(Microsoft.Build.Shared.FileExists fileExists, string currentArchitecture, string sdkToolsPath, string toolName, TaskLoggingHelper log, bool logErrorsAndWarnings)
        {
            string path = null;

            if (!string.IsNullOrEmpty(sdkToolsPath))
            {
                string str2 = string.Empty;
                try
                {
                    string str4 = currentArchitecture;
                    if (str4 == null)
                    {
                        goto Label_0061;
                    }
                    if (!(str4 == "AMD64"))
                    {
                        if (str4 == "IA64")
                        {
                            goto Label_0053;
                        }
                        if (str4 == "x86")
                        {
                        }
                        goto Label_0061;
                    }
                    str2 = Path.Combine(sdkToolsPath, "x64");
                    goto Label_0063;
Label_0053:
                    str2 = Path.Combine(sdkToolsPath, "ia64");
                    goto Label_0063;
Label_0061:
                    str2 = sdkToolsPath;
Label_0063:
                    path = Path.Combine(str2, toolName);
                    if (!fileExists(path))
                    {
                        if (currentArchitecture != "x86")
                        {
                            path = Path.Combine(sdkToolsPath, toolName);
                        }
                    }
                    else
                    {
                        return(path);
                    }
                }
                catch (ArgumentException exception)
                {
                    log.LogErrorWithCodeFromResources("General.SdkToolsPathError", new object[] { toolName, exception.Message });
                    return(null);
                }
                if (fileExists(path))
                {
                    return(path);
                }
                if (logErrorsAndWarnings)
                {
                    log.LogWarningWithCodeFromResources("General.PlatformSDKFileNotFoundSdkToolsPath", new object[] { toolName, str2, sdkToolsPath });
                }
            }
            else if (logErrorsAndWarnings)
            {
                log.LogMessageFromResources(MessageImportance.Low, "General.SdkToolsPathNotSpecifiedOrToolDoesNotExist", new object[] { toolName, sdkToolsPath });
            }
            if ((path == null) || !fileExists(path))
            {
                path = FindSDKToolUsingToolsLocationHelper(toolName);
                if ((path == null) && logErrorsAndWarnings)
                {
                    log.LogErrorWithCodeFromResources("General.SdkToolsPathToolDoesNotExist", new object[] { toolName, sdkToolsPath, ToolLocationHelper.GetDotNetFrameworkSdkRootRegistryKey(TargetDotNetFrameworkVersion.Version40) });
                }
            }
            return(path);
        }
 public AssemblyFoldersExResolver(string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, GetAssemblyRuntimeVersion getRuntimeVersion, OpenBaseKey openBaseKey, Version targetedRuntimeVesion, ProcessorArchitecture targetProcessorArchitecture, bool compareProcessorArchitecture) : base(searchPathElement, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVesion, targetProcessorArchitecture, compareProcessorArchitecture)
 {
     this.getRegistrySubKeyNames        = getRegistrySubKeyNames;
     this.getRegistrySubKeyDefaultValue = getRegistrySubKeyDefaultValue;
     this.openBaseKey = openBaseKey;
 }
 internal void SetFinalCopyLocalState(AssemblyNameExtension assemblyName, string[] frameworkPaths, ProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, Microsoft.Build.Shared.FileExists fileExists, bool copyLocalDependenciesWhenParentReferenceInGac, ReferenceTable referenceTable, CheckIfAssemblyInGac checkIfAssemblyInGac)
 {
     if (this.IsUnresolvable)
     {
         this.copyLocalState = CopyLocalState.NoBecauseUnresolved;
     }
     else if (this.EmbedInteropTypes)
     {
         this.copyLocalState = CopyLocalState.NoBecauseEmbedded;
     }
     else if (this.IsConflictVictim)
     {
         this.copyLocalState = CopyLocalState.NoBecauseConflictVictim;
     }
     else
     {
         if (this.IsPrimary)
         {
             bool flag;
             bool flag2 = MetadataConversionUtilities.TryConvertItemMetadataToBool(this.PrimarySourceItem, "Private", out flag);
             if (flag)
             {
                 if (flag2)
                 {
                     this.copyLocalState = CopyLocalState.YesBecauseReferenceItemHadMetadata;
                     return;
                 }
                 this.copyLocalState = CopyLocalState.NoBecauseReferenceItemHadMetadata;
                 return;
             }
         }
         else
         {
             bool flag3 = false;
             bool flag4 = false;
             foreach (DictionaryEntry entry in this.sourceItems)
             {
                 bool flag5;
                 bool flag6 = MetadataConversionUtilities.TryConvertItemMetadataToBool((ITaskItem)entry.Value, "Private", out flag5);
                 if (flag5)
                 {
                     if (flag6)
                     {
                         flag3 = true;
                         break;
                     }
                     flag4 = true;
                 }
             }
             if (flag4 && !flag3)
             {
                 this.copyLocalState = CopyLocalState.NoBecauseReferenceItemHadMetadata;
                 return;
             }
         }
         if (this.IsPrerequisite && !this.UserRequestedSpecificFile)
         {
             this.copyLocalState = CopyLocalState.NoBecausePrerequisite;
         }
         else if (IsFrameworkFile(this.fullPath, frameworkPaths))
         {
             this.copyLocalState = CopyLocalState.NoBecauseFrameworkFile;
         }
         else
         {
             if (!this.FoundInGac.HasValue)
             {
                 bool flag7 = checkIfAssemblyInGac(assemblyName, targetProcessorArchitecture, getRuntimeVersion, targetedRuntimeVersion, fileExists);
                 this.FoundInGac = new bool?(flag7);
             }
             if (this.FoundInGac.Value)
             {
                 this.copyLocalState = CopyLocalState.NoBecauseReferenceFoundInGAC;
             }
             else
             {
                 if (!this.IsPrimary && !copyLocalDependenciesWhenParentReferenceInGac)
                 {
                     bool flag8 = false;
                     foreach (DictionaryEntry entry2 in this.sourceItems)
                     {
                         AssemblyNameExtension referenceFromItemSpec = referenceTable.GetReferenceFromItemSpec((string)entry2.Key);
                         Reference             reference             = referenceTable.GetReference(referenceFromItemSpec);
                         bool flag9 = false;
                         if (!reference.FoundInGac.HasValue)
                         {
                             flag9 = checkIfAssemblyInGac(referenceFromItemSpec, targetProcessorArchitecture, getRuntimeVersion, targetedRuntimeVersion, fileExists);
                             reference.FoundInGac = new bool?(flag9);
                         }
                         else
                         {
                             flag9 = reference.FoundInGac.Value;
                         }
                         if (!flag9)
                         {
                             flag8 = true;
                             break;
                         }
                     }
                     if (!flag8)
                     {
                         this.copyLocalState = CopyLocalState.NoBecauseParentReferencesFoundInGAC;
                         return;
                     }
                 }
                 this.copyLocalState = CopyLocalState.YesBecauseOfHeuristic;
             }
         }
     }
 }
Пример #8
0
        internal static string GetLocation(AssemblyNameExtension strongName, ProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, bool fullFusionName, Microsoft.Build.Shared.FileExists fileExists, GetPathFromFusionName getPathFromFusionName, GetGacEnumerator getGacEnumerator, bool specificVersion)
        {
            string str = null;

            if (((strongName.GetPublicKeyToken() == null) || (strongName.GetPublicKeyToken().Length == 0)) && (strongName.FullName.IndexOf("PublicKeyToken", StringComparison.OrdinalIgnoreCase) != -1))
            {
                return(str);
            }
            getPathFromFusionName = getPathFromFusionName ?? pathFromFusionName;
            getGacEnumerator      = getGacEnumerator ?? gacEnumerator;
            if (!strongName.HasProcessorArchitectureInFusionName)
            {
                if ((targetProcessorArchitecture != ProcessorArchitecture.MSIL) && (targetProcessorArchitecture != ProcessorArchitecture.None))
                {
                    string str2 = ResolveAssemblyReference.ProcessorArchitectureToString(targetProcessorArchitecture);
                    if (fullFusionName)
                    {
                        str = CheckForFullFusionNameInGac(strongName, str2, getPathFromFusionName);
                    }
                    else
                    {
                        str = GetLocationImpl(strongName, str2, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion);
                    }
                    if ((str != null) && (str.Length > 0))
                    {
                        return(str);
                    }
                }
                if (fullFusionName)
                {
                    str = CheckForFullFusionNameInGac(strongName, "MSIL", getPathFromFusionName);
                }
                else
                {
                    str = GetLocationImpl(strongName, "MSIL", getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion);
                }
                if ((str != null) && (str.Length > 0))
                {
                    return(str);
                }
            }
            if (fullFusionName)
            {
                str = CheckForFullFusionNameInGac(strongName, null, getPathFromFusionName);
            }
            else
            {
                str = GetLocationImpl(strongName, null, getRuntimeVersion, targetedRuntimeVersion, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion);
            }
            if ((str != null) && (str.Length > 0))
            {
                return(str);
            }
            return(null);
        }
Пример #9
0
        private static SortedDictionary <Version, SortedDictionary <AssemblyNameExtension, string> > GenerateListOfAssembliesByRuntime(string strongName, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntime, Microsoft.Build.Shared.FileExists fileExists, GetPathFromFusionName getPathFromFusionName, GetGacEnumerator getGacEnumerator, bool specificVersion)
        {
            Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgumentNull(targetedRuntime, "targetedRuntime");
            IEnumerable <AssemblyNameExtension> enumerable = getGacEnumerator(strongName);
            SortedDictionary <Version, SortedDictionary <AssemblyNameExtension, string> > dictionary = new SortedDictionary <Version, SortedDictionary <AssemblyNameExtension, string> >(ReverseVersionGenericComparer.Comparer);

            if (enumerable != null)
            {
                foreach (AssemblyNameExtension extension in enumerable)
                {
                    string str = getPathFromFusionName(extension.FullName);
                    if (!string.IsNullOrEmpty(str) && fileExists(str))
                    {
                        Version version = VersionUtilities.ConvertToVersion(getRuntimeVersion(str));
                        if ((version != null) && ((targetedRuntime.CompareTo(version) >= 0) || specificVersion))
                        {
                            SortedDictionary <AssemblyNameExtension, string> dictionary2 = null;
                            dictionary.TryGetValue(version, out dictionary2);
                            if (dictionary2 == null)
                            {
                                dictionary2 = new SortedDictionary <AssemblyNameExtension, string>(AssemblyNameReverseVersionComparer.GenericComparer);
                                dictionary.Add(version, dictionary2);
                            }
                            if (!dictionary2.ContainsKey(extension))
                            {
                                dictionary2.Add(extension, str);
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
Пример #10
0
        private static string GetLocationImpl(AssemblyNameExtension assemblyName, string targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntime, Microsoft.Build.Shared.FileExists fileExists, GetPathFromFusionName getPathFromFusionName, GetGacEnumerator getGacEnumerator, bool specificVersion)
        {
            Microsoft.Build.Shared.ErrorUtilities.VerifyThrowArgumentNull(assemblyName, "assemblyName");
            Microsoft.Build.Shared.ErrorUtilities.VerifyThrow(assemblyName.FullName != null, "Got a null assembly name fullname.");
            string fullName = assemblyName.FullName;

            if ((targetProcessorArchitecture != null) && !assemblyName.HasProcessorArchitectureInFusionName)
            {
                fullName = fullName + ", ProcessorArchitecture=" + targetProcessorArchitecture;
            }
            string str2 = string.Empty;
            SortedDictionary <Version, SortedDictionary <AssemblyNameExtension, string> > dictionary = GenerateListOfAssembliesByRuntime(fullName, getRuntimeVersion, targetedRuntime, fileExists, getPathFromFusionName, getGacEnumerator, specificVersion);

            if (dictionary != null)
            {
                foreach (SortedDictionary <AssemblyNameExtension, string> dictionary2 in dictionary.Values)
                {
                    if (dictionary2.Count <= 0)
                    {
                        continue;
                    }
                    foreach (KeyValuePair <AssemblyNameExtension, string> pair in dictionary2)
                    {
                        str2 = pair.Value;
                        break;
                    }
                    if (!string.IsNullOrEmpty(str2))
                    {
                        return(str2);
                    }
                }
            }
            return(str2);
        }
Пример #11
0
 public RawFilenameResolver(string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion) : base(searchPathElement, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVesion, ProcessorArchitecture.None, false)
 {
 }
 internal Microsoft.Build.Shared.FileExists CacheDelegate(Microsoft.Build.Shared.FileExists fileExistsValue)
 {
     this.fileExists = fileExistsValue;
     return new Microsoft.Build.Shared.FileExists(this.FileExists);
 }
        internal static string StripTypeLibNumberFromPath(string typeLibPath, Microsoft.Build.Shared.FileExists fileExists)
        {
            bool flag = false;

            if (((typeLibPath != null) && (typeLibPath.Length > 0)) && !fileExists(typeLibPath))
            {
                int length = typeLibPath.LastIndexOf('\\');
                if (length == -1)
                {
                    flag = true;
                }
                else
                {
                    bool flag2 = true;
                    for (int i = length + 1; i < typeLibPath.Length; i++)
                    {
                        if (!char.IsDigit(typeLibPath[i]))
                        {
                            flag2 = false;
                            break;
                        }
                    }
                    if (flag2)
                    {
                        typeLibPath = typeLibPath.Substring(0, length);
                        if (!fileExists(typeLibPath))
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        flag = true;
                    }
                }
            }
            if (flag)
            {
                IntPtr handle = Microsoft.Build.Shared.NativeMethodsShared.LoadLibrary(typeLibPath);
                if (IntPtr.Zero != handle)
                {
                    try
                    {
                        StringBuilder wrapper = new StringBuilder(Microsoft.Build.Shared.NativeMethodsShared.MAX_PATH);
                        HandleRef     hModule = new HandleRef(wrapper, handle);
                        if ((Microsoft.Build.Shared.NativeMethodsShared.GetModuleFileName(hModule, wrapper, wrapper.Capacity) != 0) && (Marshal.GetLastWin32Error() != -2147024774))
                        {
                            typeLibPath = wrapper.ToString();
                            return(typeLibPath);
                        }
                        typeLibPath = "";
                        return(typeLibPath);
                    }
                    finally
                    {
                        Microsoft.Build.Shared.NativeMethodsShared.FreeLibrary(handle);
                    }
                }
                typeLibPath = "";
            }
            return(typeLibPath);
        }
Пример #14
0
 internal Microsoft.Build.Shared.FileExists CacheDelegate(Microsoft.Build.Shared.FileExists fileExistsValue)
 {
     this.fileExists = fileExistsValue;
     return(new Microsoft.Build.Shared.FileExists(this.FileExists));
 }
 public CandidateAssemblyFilesResolver(string[] candidateAssemblyFiles, string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion) : base(searchPathElement, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVesion, ProcessorArchitecture.None, false)
 {
     this.candidateAssemblyFiles = candidateAssemblyFiles;
 }
Пример #16
0
        public void PrivateItemInFrameworksGetsCopyLocalTrue()
        {
            // Create the engine.
            MockEngine engine = new MockEngine();

            // Create the mocks.
            Microsoft.Build.Shared.FileExists fileExists = new Microsoft.Build.Shared.FileExists(FileExists);
            Microsoft.Build.Shared.DirectoryExists directoryExists = new Microsoft.Build.Shared.DirectoryExists(DirectoryExists);
            Microsoft.Build.Tasks.GetDirectories getDirectories = new Microsoft.Build.Tasks.GetDirectories(GetDirectories);
            Microsoft.Build.Tasks.GetAssemblyName getAssemblyName = new Microsoft.Build.Tasks.GetAssemblyName(GetAssemblyName);
            Microsoft.Build.Tasks.GetAssemblyMetadata getAssemblyMetadata = new Microsoft.Build.Tasks.GetAssemblyMetadata(GetAssemblyMetadata);

            // Also construct a set of assembly names to pass in.
            ITaskItem[] assemblyNames = new TaskItem[]
            {
                new TaskItem("System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
            };

            assemblyNames[0].SetMetadata("Private", "true"); // Fx file, but user chose private=true.

            // Now, pass feed resolved primary references into ResolveAssemblyReference.
            ResolveAssemblyReference t = new ResolveAssemblyReference();

            t.BuildEngine = engine;
            t.Assemblies = assemblyNames;
            t.TargetFrameworkDirectories = new string[] { @"c:\WINNT\Microsoft.NET\Framework\v2.0.MyVersion" };
            t.SearchPaths = DefaultPaths;
            Execute(t);
            Assert.Equal(@"true", t.ResolvedFiles[0].GetMetadata("CopyLocal"));
        }
 public GacResolver(ProcessorArchitecture targetProcessorArchitecture, string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion) : base(searchPathElement, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVesion, targetProcessorArchitecture, true)
 {
 }
Пример #18
0
 public static Microsoft.Build.Tasks.Resolver[] CompileSearchPaths(string[] searchPaths, string[] candidateAssemblyFiles, ProcessorArchitecture targetProcessorArchitecture, string[] frameworkPaths, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyName getAssemblyName, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, OpenBaseKey openBaseKey, InstalledAssemblies installedAssemblies, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion)
 {
     Microsoft.Build.Tasks.Resolver[] resolverArray = new Microsoft.Build.Tasks.Resolver[searchPaths.Length];
     for (int i = 0; i < searchPaths.Length; i++)
     {
         string strA = searchPaths[i];
         if (string.Compare(strA, "{hintpathfromitem}", StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new HintPathResolver(searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
         else if (string.Compare(strA, "{targetframeworkdirectory}", StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new FrameworkPathResolver(frameworkPaths, installedAssemblies, searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
         else if (string.Compare(strA, "{rawfilename}", StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new RawFilenameResolver(searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
         else if (string.Compare(strA, "{candidateassemblyfiles}", StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new CandidateAssemblyFilesResolver(candidateAssemblyFiles, searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
         else if (string.Compare(strA, "{gac}", StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new GacResolver(targetProcessorArchitecture, searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
         else if (string.Compare(strA, "{assemblyfolders}", StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new AssemblyFoldersResolver(searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
         else if (string.Compare(strA, 0, "{registry:", 0, "{registry:".Length, StringComparison.OrdinalIgnoreCase) == 0)
         {
             resolverArray[i] = new AssemblyFoldersExResolver(searchPaths[i], getAssemblyName, fileExists, getRegistrySubKeyNames, getRegistrySubKeyDefaultValue, getRuntimeVersion, openBaseKey, targetedRuntimeVersion, targetProcessorArchitecture, true);
         }
         else
         {
             resolverArray[i] = new DirectoryResolver(searchPaths[i], getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion);
         }
     }
     return(resolverArray);
 }
Пример #19
0
        internal static Microsoft.Build.Tasks.Resolver[] CompileDirectories(IEnumerable <string> directories, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyName getAssemblyName, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion)
        {
            List <Microsoft.Build.Tasks.Resolver> list = new List <Microsoft.Build.Tasks.Resolver>();

            foreach (string str in directories)
            {
                list.Add(new DirectoryResolver(str, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVersion));
            }
            return(list.ToArray());
        }
Пример #20
0
        private bool TouchFile(string file, DateTime dt, Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.FileCreate fileCreate, GetAttributes fileGetAttributes, SetAttributes fileSetAttributes, SetLastAccessTime fileSetLastAccessTime, SetLastWriteTime fileSetLastWriteTime)
        {
            if (!fileExists(file))
            {
                if (!this.AlwaysCreate)
                {
                    base.Log.LogErrorWithCodeFromResources("Touch.FileDoesNotExist", new object[] { file });
                    return(false);
                }
                base.Log.LogMessageFromResources(MessageImportance.Normal, "Touch.CreatingFile", new object[] { file, "AlwaysCreate" });
                if (!this.CreateFile(file, fileCreate))
                {
                    return(false);
                }
            }
            else
            {
                base.Log.LogMessageFromResources(MessageImportance.Normal, "Touch.Touching", new object[] { file });
            }
            bool           flag       = false;
            FileAttributes attributes = fileGetAttributes(file);

            if (((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) && this.ForceTouch)
            {
                try
                {
                    FileAttributes attributes2 = attributes & ~FileAttributes.ReadOnly;
                    fileSetAttributes(file, attributes2);
                    flag = true;
                }
                catch (Exception exception)
                {
                    if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception))
                    {
                        throw;
                    }
                    base.Log.LogErrorWithCodeFromResources("Touch.CannotMakeFileWritable", new object[] { file, exception.Message });
                    return(false);
                }
            }
            bool flag2 = true;

            try
            {
                fileSetLastAccessTime(file, dt);
                fileSetLastWriteTime(file, dt);
            }
            catch (Exception exception2)
            {
                if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception2))
                {
                    throw;
                }
                base.Log.LogErrorWithCodeFromResources("Touch.CannotTouch", new object[] { file, exception2.Message });
                return(false);
            }
            finally
            {
                if (flag)
                {
                    try
                    {
                        fileSetAttributes(file, attributes);
                    }
                    catch (Exception exception3)
                    {
                        if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception3))
                        {
                            throw;
                        }
                        base.Log.LogErrorWithCodeFromResources("Touch.CannotRestoreAttributes", new object[] { file, exception3.Message });
                        flag2 = false;
                    }
                }
            }
            return(flag2);
        }
Пример #21
0
 public FrameworkPathResolver(string[] frameworkPaths, InstalledAssemblies installedAssemblies, string searchPathElement, GetAssemblyName getAssemblyName, Microsoft.Build.Shared.FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion) : base(searchPathElement, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVesion, ProcessorArchitecture.None, false)
 {
     this.frameworkPaths      = frameworkPaths;
     this.installedAssemblies = installedAssemblies;
 }