Esempio n. 1
0
        //
        // Generate the necessary file lists and other information required by MarkupCompiler.
        //
        // Output ArrayLists:  localApplicationFile,
        //                     localXamlPageFileList
        //                     referenceList
        //
        private void PrepareForMarkupCompilation(out FileUnit localApplicationFile, out FileUnit[] localXamlPageFileList, out ArrayList referenceList)
        {
            Log.LogMessageFromResources(MessageImportance.Low, SRID.PreparingCompile);
            Log.LogMessageFromResources(MessageImportance.Low, SRID.OutputType, OutputType);

            // Initialize the output parameters
            localXamlPageFileList = new FileUnit[0];
            localApplicationFile  = FileUnit.Empty;
            referenceList         = new ArrayList();

            if (_localApplicationFile != null)
            {
                // We don't want to support multiple application definition file per project.
                localApplicationFile = new FileUnit(_localApplicationFile.FilePath, _localApplicationFile.LinkAlias, _localApplicationFile.LogicalName);

                Log.LogMessageFromResources(MessageImportance.Low, SRID.LocalRefAppDefFile, localApplicationFile);
            }

            // Generate the Xaml Markup file list
            if (_localMarkupPages != null && _localMarkupPages.Length > 0)
            {
                int localFileNum = _localMarkupPages.Length;
                localXamlPageFileList = new FileUnit[localFileNum];

                for (int i = 0; i < localFileNum; i++)
                {
                    FileUnit localPageFile = new FileUnit(_localMarkupPages[i].FilePath, _localMarkupPages[i].LinkAlias, _localMarkupPages[i].LogicalName);

                    localXamlPageFileList[i] = localPageFile;
                    Log.LogMessageFromResources(MessageImportance.Low, SRID.LocalRefMarkupPage, localPageFile);
                }
            }

            //
            // Generate the asmmebly reference list.
            // The temporay target assembly should have been added into Reference list from target file.
            //
            if (References != null && References.Length > 0)
            {
                ReferenceAssembly asmReference;
                string            refpath, asmname;

                for (int i = 0; i < References.Length; i++)
                {
                    refpath = References[i].ItemSpec;
                    refpath = TaskHelper.CreateFullFilePath(refpath, SourceDir);

                    asmname = Path.GetFileNameWithoutExtension(refpath);

                    asmReference = new ReferenceAssembly(refpath, asmname);
                    referenceList.Add(asmReference);

                    //
                    // If always run the compilation in second appdomain, there is no need to specially
                    // handle the referenced assemblies.
                    // Unload the appdomain can unload all the referenced assemblies.
                    //
                    if (AlwaysCompileMarkupFilesInSeparateDomain == false)
                    {
                        bool bCouldbeChanged = TaskHelper.CouldReferenceAssemblyBeChanged(refpath, KnownReferencePaths, AssembliesGeneratedDuringBuild);

                        if (bCouldbeChanged)
                        {
                            MarkupCompiler.InitializeAssemblyState(asmname);
                        }
                    }
                }
            }
        }