Add a auto-generated header to the assembly info file that is created on build

This commit is contained in:
Dennis Fischer 2016-02-04 22:05:17 +01:00
parent 268dd603cc
commit 61281b4580
3 changed files with 6 additions and 4 deletions

View file

@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
{
public class AssemblyInfoFileGenerator
{
public static string Generate(AssemblyInfoOptions metadata, IEnumerable<string> sourceFiles)
public static string GenerateCSharp(AssemblyInfoOptions metadata, IEnumerable<string> sourceFiles)
{
var projectAttributes = GetProjectAttributes(metadata);
@ -43,7 +43,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
}
}
return string.Join(Environment.NewLine, projectAttributes
string autoGeneratedHeader = "// <auto-generated> This file has been auto generated. </auto-generated>\r\n";
return autoGeneratedHeader + string.Join(Environment.NewLine, projectAttributes
.Where(projectAttribute => projectAttribute.Value != null && !existingAttributes.Contains(projectAttribute.Key))
.Select(projectAttribute => $"[assembly:{projectAttribute.Key.FullName}(\"{projectAttribute.Value}\")]"));
}

View file

@ -90,7 +90,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
// Generate assembly info
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs");
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.Generate(assemblyInfoOptions, sources));
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateCSharp(assemblyInfoOptions, sources));
allArgs.Add($"\"{assemblyInfo}\"");
if (outputName != null)

View file

@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Tools.Resgen
compilation = compilation.AddSyntaxTrees(new[]
{
CSharpSyntaxTree.ParseText(AssemblyInfoFileGenerator.Generate(metadata, Enumerable.Empty<string>()))
CSharpSyntaxTree.ParseText(AssemblyInfoFileGenerator.GenerateCSharp(metadata, Enumerable.Empty<string>()))
});
var result = compilation.Emit(outputStream, manifestResources: resourceDescriptions);