Exemple #1
0
        private IEnumerable <AssemblyInfoFile> GetAssemblyInfoFiles()
        {
            List <AssemblyInfoFile> fileList = new List <AssemblyInfoFile>();

            foreach (ITaskItem item in this.assemblyInfoFileItems)
            {
                string filePath = null;
                try
                {
                    if (item.ItemSpec.Length != 0)
                    {
                        filePath = item.GetMetadata("FullPath");
                        using (Stream fileStream = File.OpenRead(filePath))
                        {
                            AssemblyInfoFile file = new AssemblyInfoFile()
                            {
                                Template   = item.GetMetadata("Identity"),
                                OutputFile = item.GetMetadata("OutputFile")
                            };
                            fileList.Add(file);
                            Log.LogMessage("  \"{0}\" -> \"{1}\"", new object[] { file.Template, file.OutputFile ?? Path.GetFileName(file.Template) });
                        }
                    }
                }
                catch (ArgumentException)
                {
                    throw;
                }
                catch (Exception)
                {
                    if (filePath != null)
                    {
                        Log.LogError("Unable to open file: {0}", new object[] { filePath });
                    }
                }
            }
            return(fileList);
        }
		private IEnumerable<AssemblyInfoFile> GetAssemblyInfoFiles()
		{
			List<AssemblyInfoFile> fileList = new List<AssemblyInfoFile>();
			foreach ( ITaskItem item in this.assemblyInfoFileItems )
			{
				string filePath = null;
				try
				{
					if ( item.ItemSpec.Length != 0 )
					{
						filePath = item.GetMetadata( "FullPath" );
						using ( Stream fileStream = File.OpenRead( filePath ) )
						{
							AssemblyInfoFile file = new AssemblyInfoFile()
							{
								Template = item.GetMetadata( "Identity" ),
								OutputFile = item.GetMetadata( "OutputFile" )
							};
							fileList.Add( file );
							Log.LogMessage( "  \"{0}\" -> \"{1}\"", new object[] { file.Template, file.OutputFile ?? Path.GetFileName( file.Template ) } );
						}
					}
				}
				catch ( ArgumentException )
				{
					throw;
				}
				catch ( Exception )
				{
					if ( filePath != null )
					{
						Log.LogError( "Unable to open file: {0}", new object[] { filePath } );
					}
				}
			}
			return fileList;
		}