示例#1
0
        /// <summary>
        /// Records a list of the generated files in the LastOutputs metadata of the input item.
        /// </summary>
        private void RecordLastOutputs()
        {
            string lastGenOutputFullPath = this.GetLastGenOutputFullPath();

            // Create a list of files that may be regenerated/overwritten in the future
            var outputFileList = new List <string>();

            foreach (OutputFile output in this.outputFiles)
            {
                // Don't store the name of file user wants to preserve so that we don't deleted next time.
                if (output.PreserveExistingFile)
                {
                    continue;
                }

                // Don't store the name of default output file second time
                string outputFullPath = this.GetFullPath(output.Path);
                if (string.Equals(lastGenOutputFullPath, outputFullPath, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                // Store a relative path from the input file to the output file
                outputFileList.Add(FileMethods.GetRelativePath(this.inputFile, outputFullPath));
            }

            // If more than one output file was generated, write one file per line in alphabetical order for readability
            outputFileList.Sort();
            string lastOutputs = string.Join(Environment.NewLine, outputFileList);

            if (outputFileList.Count > 1)
            {
                lastOutputs = Environment.NewLine + lastOutputs + Environment.NewLine;
            }

            // Write the file list to the project file
            this.input.SetItemAttribute(ItemMetadata.LastOutputs, lastOutputs);
        }