Exemplo n.º 1
0
        public override int Save(string fileToBeSaved, int remember, uint formatIndex)
        {
            // Would like to add the targets import in InitializeProjectProperties but
            // using relative paths can cause issues when the project is created from the template
            // where the relative import path is evaluated against the template path rather
            // than the eventual project path.

            // If the file name here and the the file name on the build engine's project
            // are the same then fix up the import.

            if (string.Compare(fileToBeSaved, BuildProject.FullFileName, true) == 0)
            {
                string[] targetsFiles = GetProjectTargetsFiles();

                if (targetsFiles != null)
                {
                    foreach (string targetsFile in targetsFiles)
                    {
                        // Look for the targets import.

                        bool found = false;
                        foreach (Import import in BuildProject.Imports)
                        {
                            if (string.Compare(Path.GetFileName(import.EvaluatedProjectPath), targetsFile, true) == 0)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            // Add the import now.

                            string projectPath = Path.GetDirectoryName(FileName);
                            string targetsPath = StaticEnvironment.GetFilePath(Constants.Product.Sdk, Path.Combine(Constants.Folder.Bin, Constants.Folder.Targets), targetsFile);
                            string import      = FilePath.GetRelativePath(targetsPath, projectPath);
                            BuildProject.AddNewImport(import, string.Empty);
                        }
                    }
                }
            }

            return(base.Save(fileToBeSaved, remember, formatIndex));
        }